Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLSP-1363: Bundle CLI tool #1364

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
module.exports = {
root: true,
extends: '@eclipse-glsp',
ignorePatterns: ['**/{node_modules,lib}', '**/.eslintrc.js'],
ignorePatterns: ['**/{node_modules,lib}', '**/.eslintrc.js', '**/esbuild.js'],

parserOptions: {
tsconfigRootDir: __dirname,
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
*.log
lib
dist
tsconfig.tsbuildinfo
eslint.xml
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: Pod
spec:
containers:
- name: node
image: eclipseglsp/ci:alpine-v4.0
image: eclipseglsp/ci:alpine-v5.0
tty: true
resources:
limits:
Expand Down
10 changes: 0 additions & 10 deletions dev-packages/cli/.eslintrc.js

This file was deleted.

2 changes: 0 additions & 2 deletions dev-packages/cli/bin/glsp

This file was deleted.

30 changes: 30 additions & 0 deletions dev-packages/cli/esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const esbuild = require('esbuild');

/** @param {import('esbuild').BuildOptions} context. */
async function doWatch(options) {
const ctx = await esbuild.context(options);
await ctx.watch();
console.log('Watching for changes...');
}

/** @type {import('esbuild').BuildOptions} */
const opts = {
entryPoints: ['src/cli.ts'],
bundle: true,
outfile: 'dist/cli.js',
platform: 'node',
sourcemap: true,
packages: 'external'
};

const production = process.argv.includes('-p') || process.argv.includes('--production');
if (production) {
opts.minify = true;
opts.sourcemap = false;
}
const watch = process.argv.includes('-w') || process.argv.includes('--watch');
if (!watch) {
esbuild.build(opts).catch(() => process.exit(1));
} else {
doWatch(opts);
}
37 changes: 17 additions & 20 deletions dev-packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
"name": "@eclipse-glsp/cli",
"version": "2.2.0-next",
"description": "CLI Tooling & scripts for GLSP components",
"keywords": [
"eclipse",
"tsconfig"
],
"homepage": "https://www.eclipse.org/glsp/",
"bugs": "https://github.com/eclipse-glsp/glsp/issues",
"repository": {
Expand All @@ -24,23 +20,32 @@
}
],
"bin": {
"glsp": "bin/glsp"
"glsp": "dist/cli.js"
},
"files": [
"src",
"bin",
"lib"
"dist"
],
"scripts": {
"build": "tsc -b",
"clean": "rimraf lib tsconfig.tsbuildinfo",
"bundle": "node esbuild.js",
"bundle:prod": "yarn clean dist && yarn bundle --production",
"clean": "rimraf lib dist tsconfig.tsbuildinfo",
"clean:dist": "rimraf dist",
"lint": "eslint --ext .ts,.tsx ./src",
"lint:ci": "yarn lint -o eslint.xml -f checkstyle",
"start": "node --enable-source-maps lib/app.js",
"watch": "tsc -w"
"start": "node --enable-source-maps dist/cli.js",
"watch": "node esbuild.js -w",
"watch:tsc": "tsc -b -w"
},
"dependencies": {
"devDependencies": {
"@eclipse-glsp/config": "2.2.0-next",
"@types/glob": "^8.1.0",
"@types/node-fetch": "^2.6.6",
"@types/readline-sync": "^1.4.5",
"@types/semver": "^7.5.3",
"@types/shelljs": "^0.8.13",
"commander": "^10.0.1",
"esbuild": "~0.21.5",
"glob": "^10.3.10",
"globby": "13.2.2",
"node-fetch": "^2.6.11",
Expand All @@ -49,14 +54,6 @@
"semver": "^7.5.1",
"shelljs": "^0.8.5"
},
"devDependencies": {
"@eclipse-glsp/config": "2.2.0-next",
"@types/glob": "^8.1.0",
"@types/node-fetch": "^2.6.6",
"@types/readline-sync": "^1.4.5",
"@types/semver": "^7.5.3",
"@types/shelljs": "^0.8.13"
},
"publishConfig": {
"access": "public"
}
Expand Down
3 changes: 1 addition & 2 deletions dev-packages/cli/src/app.ts → dev-packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
/********************************************************************************
* Copyright (c) 2022 EclipseSource and others.
* Copyright (c) 2022-2024 EclipseSource and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -22,7 +22,6 @@ import { UpdateNextCommand } from './commands/update-next';
import { baseCommand } from './util/command-util';

export const COMMAND_VERSION = '1.1.0-next';

const app = baseCommand() //
.version(COMMAND_VERSION)
.name('glsp')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
updateLernaForDryRun,
updateVersion,
yarnInstall
} from './common.js';
} from './common';

let REPO_ROOT: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
updateLernaForDryRun,
updateVersion,
yarnInstall
} from './common.js';
} from './common';

let REPO_ROOT: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
updateLernaForDryRun,
updateVersion,
yarnInstall
} from './common.js';
} from './common';

let REPO_ROOT: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
updateLernaForDryRun,
updateVersion,
yarnInstall
} from './common.js';
} from './common';

let REPO_ROOT: string;

Expand Down
2 changes: 1 addition & 1 deletion dev-packages/cli/src/commands/release/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
asMvnVersion,
checkIfMavenVersionExists,
checkIfNpmVersionIsNew
} from './common.js';
} from './common';
import { releaseClient } from './release-client';
import { releaseEclipseIntegration } from './release-eclipse-integration';
import { releaseJavaServer } from './release-java-server';
Expand Down
4 changes: 2 additions & 2 deletions dev-packages/ts-config/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"resolveJsonModule": true,
"module": "CommonJS",
"moduleResolution": "Node",
"target": "ES2017",
"target": "ES2019",
"jsx": "react",
"lib": ["ES2017", "dom"],
"lib": ["ES2019", "Dom"],
"sourceMap": true,
"types": ["node", "reflect-metadata"]
}
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
],
"scripts": {
"all": "yarn install && yarn lint",
"build": "yarn compile",
"build": "yarn compile && yarn cli bundle",
"check:headers": "yarn start:cli checkHeaders . -t lastCommit",
"check:pr": "yarn all && yarn check:headers",
"clean": "lerna run clean",
"cli": " yarn --cwd dev-packages/cli",
"compile": "tsc -b",
"lint": "eslint --ext .ts,.tsx .",
"lint:ci": "yarn lint -o eslint.xml -f checkstyle",
Expand All @@ -19,8 +20,7 @@
"publish:latest": "lerna publish from-git --no-git-reset --no-git-tag-version --no-verify-access --no-push",
"publish:next": "lerna publish preminor --exact --canary --preid next --dist-tag next --no-git-reset --no-git-tag-version --no-push --ignore-scripts --yes",
"publish:prepare": "lerna version --ignore-scripts --yes --no-push",
"start:cli": " yarn --cwd dev-packages/cli start",
"watch": "tsc -b -w --preserveWatchOutput"
"watch": "concurrently --kill-others -n tsc,bundle -c red,yellow \"tsc -b -w --preserveWatchOutput\" \"yarn -s cli watch\""
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
Expand All @@ -31,6 +31,7 @@
"@typescript-eslint/eslint-plugin": "^5.59.7",
"@typescript-eslint/parser": "^5.59.7",
"chai": "^4.3.7",
"concurrently": "^8.2.2",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-chai-friendly": "^0.7.2",
Expand Down
Loading
Loading