@gjsify/cli 0.0.1-b → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/actions/build.d.ts +110 -6
- package/lib/actions/build.js +94 -23
- package/lib/commands/build.d.ts +2 -17
- package/lib/commands/build.js +74 -61
- package/lib/commands/index.d.ts +1 -0
- package/lib/commands/index.js +1 -0
- package/lib/config.d.ts +14 -0
- package/lib/config.js +63 -0
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +1 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +12 -6
- package/lib/types/cli-build-options.d.ts +35 -0
- package/lib/types/cli-build-options.js +1 -0
- package/lib/types/command.d.ts +9 -0
- package/lib/types/command.js +1 -0
- package/lib/types/config-data-library.d.ts +3 -0
- package/lib/types/config-data-library.js +1 -0
- package/lib/types/config-data-typescript.d.ts +5 -0
- package/lib/types/config-data-typescript.js +1 -0
- package/lib/types/config-data.d.ts +11 -0
- package/lib/types/config-data.js +1 -0
- package/lib/types/cosmiconfig-result.d.ts +5 -0
- package/lib/types/cosmiconfig-result.js +1 -0
- package/lib/types/index.d.ts +6 -1
- package/lib/types/index.js +6 -2
- package/package.json +31 -82
- package/src/actions/build.ts +117 -0
- package/src/actions/index.ts +1 -0
- package/src/commands/build.ts +80 -0
- package/src/commands/index.ts +1 -0
- package/src/config.ts +80 -0
- package/src/constants.ts +1 -0
- package/src/index.ts +14 -0
- package/src/types/cli-build-options.ts +36 -0
- package/src/types/command.ts +10 -0
- package/src/types/config-data-library.ts +5 -0
- package/src/types/config-data-typescript.ts +6 -0
- package/src/types/config-data.ts +12 -0
- package/src/types/cosmiconfig-result.ts +5 -0
- package/src/types/index.ts +6 -0
- package/tsconfig.json +12 -0
- package/LICENSE +0 -21
- package/README.md +0 -79
- package/bin/run +0 -5
- package/bin/run.cmd +0 -3
- package/lib/actions/init.d.ts +0 -0
- package/lib/actions/init.js +0 -7
- package/lib/defaults.d.ts +0 -7
- package/lib/defaults.js +0 -9
- package/lib/types/build-options.d.ts +0 -10
- package/lib/types/build-options.js +0 -2
- package/lib/webpack.config.default.d.ts +0 -59
- package/lib/webpack.config.default.js +0 -94
- package/oclif.manifest.json +0 -1
package/package.json
CHANGED
|
@@ -1,90 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/cli",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "CLI for Gjsify",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"module": "lib/index.js",
|
|
8
|
+
"types": "lib/index.d.ts",
|
|
6
9
|
"bin": {
|
|
7
|
-
"gjsify": "./
|
|
8
|
-
},
|
|
9
|
-
"bugs": "https://github.com/gjsify/cli/issues",
|
|
10
|
-
"dependencies": {
|
|
11
|
-
"@gjsify/console": "0.0.1",
|
|
12
|
-
"@gjsify/fs": "0.0.1",
|
|
13
|
-
"@gjsify/os": "0.0.1",
|
|
14
|
-
"@gjsify/path": "0.0.1",
|
|
15
|
-
"@gjsify/process": "0.0.1",
|
|
16
|
-
"@oclif/command": "^1",
|
|
17
|
-
"@oclif/config": "^1",
|
|
18
|
-
"@oclif/plugin-help": "^2",
|
|
19
|
-
"assert": "^2.0.0",
|
|
20
|
-
"browserify-zlib": "^0.2.0",
|
|
21
|
-
"buffer": "^5.4.3",
|
|
22
|
-
"constants-browserify": "^1.0.0",
|
|
23
|
-
"crypto-browserify": "^3.12.0",
|
|
24
|
-
"domain-browser": "^3.5.0",
|
|
25
|
-
"events": "^3.1.0",
|
|
26
|
-
"inherits": "^2.0.4",
|
|
27
|
-
"json-loader": "^0.5.7",
|
|
28
|
-
"punycode": "^2.1.1",
|
|
29
|
-
"querystring-es3": "^0.2.1",
|
|
30
|
-
"stream-browserify": "^2.0.2",
|
|
31
|
-
"string_decoder": "^1.3.0",
|
|
32
|
-
"terser-webpack-plugin": "^2.3.5",
|
|
33
|
-
"ts-loader": "^6.2.1",
|
|
34
|
-
"tslib": "^1",
|
|
35
|
-
"tty-browserify": "0.0.1",
|
|
36
|
-
"url": "^0.11.0",
|
|
37
|
-
"util": "^0.12.2",
|
|
38
|
-
"webpack": "^4.41.6"
|
|
10
|
+
"gjsify": "./lib/index.js"
|
|
39
11
|
},
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"@types/terser-webpack-plugin": "^2.2.0",
|
|
47
|
-
"@types/webpack": "^4.41.6",
|
|
48
|
-
"chai": "^4",
|
|
49
|
-
"eslint": "^5.13",
|
|
50
|
-
"eslint-config-oclif": "^3.1",
|
|
51
|
-
"eslint-config-oclif-typescript": "^0.1",
|
|
52
|
-
"globby": "^10",
|
|
53
|
-
"mocha": "^5",
|
|
54
|
-
"nyc": "^14",
|
|
55
|
-
"ts-node": "^8",
|
|
56
|
-
"typescript": "^3.3"
|
|
57
|
-
},
|
|
58
|
-
"engines": {
|
|
59
|
-
"node": ">=8.0.0"
|
|
12
|
+
"scripts": {
|
|
13
|
+
"clear": "rm -rf lib tsconfig.tsbuildinfo tsconfig.types.tsbuildinfo || exit 0",
|
|
14
|
+
"print:name": "echo '@gjsify/cli'",
|
|
15
|
+
"start": "node lib/index.js",
|
|
16
|
+
"build": "yarn print:name && tsc && yarn chmod",
|
|
17
|
+
"chmod": "chmod +x ./lib/index.js"
|
|
60
18
|
},
|
|
61
|
-
"files": [
|
|
62
|
-
"/bin",
|
|
63
|
-
"/lib",
|
|
64
|
-
"/npm-shrinkwrap.json",
|
|
65
|
-
"/oclif.manifest.json"
|
|
66
|
-
],
|
|
67
|
-
"homepage": "https://github.com/gjsify/cli",
|
|
68
19
|
"keywords": [
|
|
69
|
-
"
|
|
20
|
+
"gjs",
|
|
21
|
+
"node",
|
|
22
|
+
"gjsify",
|
|
23
|
+
"cli"
|
|
70
24
|
],
|
|
71
|
-
"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"repository": "gjsify/cli",
|
|
81
|
-
"scripts": {
|
|
82
|
-
"postpack": "rm -f oclif.manifest.json",
|
|
83
|
-
"posttest": "eslint . --ext .ts --config .eslintrc",
|
|
84
|
-
"prepack": "rm -rf lib && npm run build && oclif-dev manifest && oclif-dev readme",
|
|
85
|
-
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
|
|
86
|
-
"version": "oclif-dev readme && git add README.md",
|
|
87
|
-
"build": "tsc -b"
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@gjsify/esbuild-plugin-deepkit": "^0.0.2",
|
|
27
|
+
"@gjsify/esbuild-plugin-gjsify": "^0.0.2",
|
|
28
|
+
"cosmiconfig": "^8.2.0",
|
|
29
|
+
"esbuild": "^0.18.2",
|
|
30
|
+
"get-tsconfig": "^4.6.0",
|
|
31
|
+
"lodash": "^4.17.21",
|
|
32
|
+
"pkg-types": "^1.0.3",
|
|
33
|
+
"yargs": "^17.7.2"
|
|
88
34
|
},
|
|
89
|
-
"
|
|
90
|
-
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/yargs": "^17.0.24",
|
|
37
|
+
"typescript": "^5.1.3"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { ConfigData } from '../types/index.js';
|
|
2
|
+
import type { App } from '@gjsify/esbuild-plugin-gjsify';
|
|
3
|
+
import { build, analyzeMetafile, BuildOptions, BuildResult } from 'esbuild';
|
|
4
|
+
import { gjsifyPlugin } from '@gjsify/esbuild-plugin-gjsify';
|
|
5
|
+
import { dirname, extname } from 'path';
|
|
6
|
+
import { writeFile } from 'fs/promises';
|
|
7
|
+
|
|
8
|
+
export class BuildAction {
|
|
9
|
+
constructor(readonly configData: ConfigData = {}) {
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
getEsBuildDefaults() {
|
|
14
|
+
const defaults: BuildOptions = {
|
|
15
|
+
allowOverwrite: true
|
|
16
|
+
}
|
|
17
|
+
return defaults;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Library mode */
|
|
21
|
+
async buildLibrary() {
|
|
22
|
+
let { verbose, library, esbuild, typescript, exclude } = this.configData;
|
|
23
|
+
library ||= {};
|
|
24
|
+
esbuild ||= {};
|
|
25
|
+
typescript ||= {};
|
|
26
|
+
|
|
27
|
+
const moduleOutdir = library?.module ? dirname(library.module) : undefined;
|
|
28
|
+
const mainOutdir = library?.main ? dirname(library.main) : undefined;
|
|
29
|
+
|
|
30
|
+
const moduleOutExt = library.module ? extname(library.module) : '.js';
|
|
31
|
+
const mainOutExt = library.main ? extname(library.main) : '.js';
|
|
32
|
+
|
|
33
|
+
const multipleBuilds = moduleOutdir && mainOutdir && (moduleOutdir !== mainOutdir);
|
|
34
|
+
|
|
35
|
+
const results: BuildResult[] = [];
|
|
36
|
+
|
|
37
|
+
if(multipleBuilds) {
|
|
38
|
+
|
|
39
|
+
const moduleFormat = moduleOutdir.includes('/cjs') || moduleOutExt === '.cjs' ? 'cjs' : 'esm';
|
|
40
|
+
results.push(await build({
|
|
41
|
+
...this.getEsBuildDefaults(),
|
|
42
|
+
...esbuild,
|
|
43
|
+
format: moduleFormat,
|
|
44
|
+
outdir: moduleOutdir,
|
|
45
|
+
plugins: [
|
|
46
|
+
gjsifyPlugin({debug: verbose, library: moduleFormat, exclude, reflection: typescript?.reflection, jsExtension: moduleOutExt}),
|
|
47
|
+
]
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
const mainFormat = mainOutdir.includes('/cjs') || mainOutExt === '.cjs' ? 'cjs' : 'esm';
|
|
51
|
+
results.push(await build({
|
|
52
|
+
...this.getEsBuildDefaults(),
|
|
53
|
+
...esbuild,
|
|
54
|
+
format: moduleFormat,
|
|
55
|
+
outdir: mainOutdir,
|
|
56
|
+
plugins: [
|
|
57
|
+
gjsifyPlugin({debug: verbose, library: mainFormat, exclude, reflection: typescript?.reflection, jsExtension: mainOutdir})
|
|
58
|
+
]
|
|
59
|
+
}));
|
|
60
|
+
} else {
|
|
61
|
+
const outfilePath = esbuild?.outfile || library?.module || library?.main;
|
|
62
|
+
const outExt = outfilePath ? extname(outfilePath) : '.js';
|
|
63
|
+
const outdir = esbuild?.outdir || (outfilePath ? dirname(outfilePath) : undefined);
|
|
64
|
+
const format = esbuild?.format || outdir?.includes('/cjs') || outExt === '.cjs' ? 'cjs' : 'esm';
|
|
65
|
+
results.push(await build({
|
|
66
|
+
...this.getEsBuildDefaults(),
|
|
67
|
+
...esbuild,
|
|
68
|
+
format,
|
|
69
|
+
outdir,
|
|
70
|
+
plugins: [
|
|
71
|
+
gjsifyPlugin({debug: verbose, library: format, exclude, reflection: typescript?.reflection, jsExtension: outExt})
|
|
72
|
+
]
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
return results;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Application mode */
|
|
79
|
+
async buildApp(app: App = 'gjs') {
|
|
80
|
+
|
|
81
|
+
const { verbose, esbuild, typescript, exclude } = this.configData;
|
|
82
|
+
|
|
83
|
+
const format: 'cjs' | 'esm' = esbuild?.format || esbuild?.outfile?.endsWith('.cjs') ? 'cjs' : 'esm';
|
|
84
|
+
|
|
85
|
+
const result = await build({
|
|
86
|
+
...this.getEsBuildDefaults(),
|
|
87
|
+
...esbuild,
|
|
88
|
+
format,
|
|
89
|
+
plugins: [
|
|
90
|
+
gjsifyPlugin({debug: verbose, app, format, exclude, reflection: typescript?.reflection}),
|
|
91
|
+
]
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// See https://esbuild.github.io/api/#metafile
|
|
95
|
+
// TODO add cli options for this
|
|
96
|
+
// if(result.metafile) {
|
|
97
|
+
// const outFile = esbuild?.outfile ? esbuild.outfile + '.meta.json' : 'meta.json';
|
|
98
|
+
// await writeFile(outFile, JSON.stringify(result.metafile));
|
|
99
|
+
|
|
100
|
+
// let text = await analyzeMetafile(result.metafile)
|
|
101
|
+
// console.log(text)
|
|
102
|
+
// }
|
|
103
|
+
|
|
104
|
+
return [result];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async start(buildType: {library?: boolean, app?: App} = {app: 'gjs'}) {
|
|
108
|
+
const results: BuildResult[] = [];
|
|
109
|
+
if(buildType.library) {
|
|
110
|
+
results.push(...(await this.buildLibrary()));
|
|
111
|
+
} else {
|
|
112
|
+
results.push(...(await this.buildApp(buildType.app)));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return results;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './build.js';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Config } from '../config.js';
|
|
2
|
+
import { BuildAction } from '../actions/build.js';
|
|
3
|
+
import type { Command, CliBuildOptions } from '../types/index.js';
|
|
4
|
+
|
|
5
|
+
export const buildCommand: Command<any, CliBuildOptions> = {
|
|
6
|
+
command: 'build [entryPoints..]',
|
|
7
|
+
description: 'Build and bundle your Gjs project',
|
|
8
|
+
builder: (yargs) => {
|
|
9
|
+
return yargs
|
|
10
|
+
.option('entry-points', {
|
|
11
|
+
description: "The entry points you want to bundle",
|
|
12
|
+
array: true,
|
|
13
|
+
type: 'string',
|
|
14
|
+
normalize: true,
|
|
15
|
+
default: ['src/index.ts'],
|
|
16
|
+
coerce: (arg: string[]) => {
|
|
17
|
+
// Removes duplicates
|
|
18
|
+
return [...new Set(arg)];
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
.option('exclude', {
|
|
22
|
+
description: "An array of glob patterns to exclude entry-points and aliases",
|
|
23
|
+
array: true,
|
|
24
|
+
type: 'string',
|
|
25
|
+
normalize: true,
|
|
26
|
+
default: []
|
|
27
|
+
})
|
|
28
|
+
.option('verbose', {
|
|
29
|
+
description: "Switch on the verbose mode",
|
|
30
|
+
type: 'boolean',
|
|
31
|
+
normalize: true,
|
|
32
|
+
default: false
|
|
33
|
+
})
|
|
34
|
+
.option('app', {
|
|
35
|
+
description: "Use this if you want to build a application, the application platforms node and deno are usually only used for tests",
|
|
36
|
+
type: 'string',
|
|
37
|
+
choices: ['gjs', 'node', 'deno', 'browser'],
|
|
38
|
+
normalize: true,
|
|
39
|
+
default: 'gjs'
|
|
40
|
+
})
|
|
41
|
+
.option('library', {
|
|
42
|
+
description: "Use this if you want to build a library for Gjsify",
|
|
43
|
+
type: 'boolean',
|
|
44
|
+
normalize: true,
|
|
45
|
+
default: false
|
|
46
|
+
})
|
|
47
|
+
.option('outfile', {
|
|
48
|
+
description: "Sets the output file name for the build operation. If no outfile is specified, the outfile will be parsed from the package.json. Only used if application mode is active",
|
|
49
|
+
type: 'string',
|
|
50
|
+
normalize: true,
|
|
51
|
+
})
|
|
52
|
+
.option('outdir', {
|
|
53
|
+
description: "Sets the output directory for the build operation. If no outdir is specified, the outdir will be parsed from the package.json. Only used if library mode is active",
|
|
54
|
+
type: 'string',
|
|
55
|
+
normalize: true,
|
|
56
|
+
})
|
|
57
|
+
.option('reflection', {
|
|
58
|
+
description: "Enables TypeScript types on runtime using Deepkit's type compiler",
|
|
59
|
+
type: 'boolean',
|
|
60
|
+
normalize: true,
|
|
61
|
+
default: false
|
|
62
|
+
})
|
|
63
|
+
.option('log-level', {
|
|
64
|
+
description: "The log level can be changed to prevent esbuild from printing warning and/or error messages to the terminal",
|
|
65
|
+
type: 'string',
|
|
66
|
+
choices: ['silent', 'error', 'warning', 'info', 'debug', 'verbose'],
|
|
67
|
+
normalize: true,
|
|
68
|
+
default: 'warning'
|
|
69
|
+
})
|
|
70
|
+
},
|
|
71
|
+
handler: async (args) => {
|
|
72
|
+
const config = new Config();
|
|
73
|
+
const configData = await config.forBuild(args);
|
|
74
|
+
const action = new BuildAction(configData);
|
|
75
|
+
await action.start({
|
|
76
|
+
library: args.library,
|
|
77
|
+
app: args.app,
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './build.js';
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { APP_NAME } from './constants.js';
|
|
2
|
+
import { cosmiconfig, Options as LoadOptions } from 'cosmiconfig';
|
|
3
|
+
import { readPackageJSON, resolvePackageJSON } from 'pkg-types';
|
|
4
|
+
import { getTsconfig } from 'get-tsconfig';
|
|
5
|
+
import lodash from "lodash";
|
|
6
|
+
const { merge } = lodash;
|
|
7
|
+
|
|
8
|
+
import type { CliBuildOptions, ConfigData, CosmiconfigResult, ConfigDataTypescript, ConfigDataLibrary} from './types/index.js';
|
|
9
|
+
import type { ArgumentsCamelCase } from 'yargs';
|
|
10
|
+
|
|
11
|
+
export class Config {
|
|
12
|
+
|
|
13
|
+
readonly loadOptions: LoadOptions = {
|
|
14
|
+
searchPlaces: [APP_NAME]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
constructor(loadOptions: LoadOptions = {}) {
|
|
18
|
+
if(Object.keys(loadOptions).length) {
|
|
19
|
+
this.loadOptions = loadOptions;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Loads gjsify config file, e.g `gjsify.js` */
|
|
24
|
+
private async load(searchFrom?: string) {
|
|
25
|
+
let configFile = await cosmiconfig(APP_NAME, this.loadOptions).search(searchFrom) as CosmiconfigResult<ConfigData> | null;
|
|
26
|
+
|
|
27
|
+
configFile ||= {
|
|
28
|
+
config: {},
|
|
29
|
+
filepath: '',
|
|
30
|
+
isEmpty: true,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
configFile.config ||= {};
|
|
34
|
+
configFile.config.esbuild ||= {};
|
|
35
|
+
configFile.config.library ||= {};
|
|
36
|
+
configFile.config.typescript ||= {};
|
|
37
|
+
return configFile;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Loads package.json of the current project */
|
|
41
|
+
private async readPackageJSON(dirPath?: string) {
|
|
42
|
+
dirPath = await resolvePackageJSON(dirPath)
|
|
43
|
+
const pkg = await readPackageJSON(dirPath);
|
|
44
|
+
return pkg;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Loads tsconfig.json of the current project */
|
|
48
|
+
private async readTSConfig(dirPath?: string) {
|
|
49
|
+
const tsconfig = getTsconfig(dirPath)?.config || {};
|
|
50
|
+
return tsconfig;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async forBuild(cliArgs: ArgumentsCamelCase<CliBuildOptions>) {
|
|
54
|
+
const configFile = await this.load(process.cwd());
|
|
55
|
+
const configData: ConfigData = {...configFile.config};
|
|
56
|
+
const configFilePath = configFile.filepath || process.cwd();
|
|
57
|
+
const pkg = await this.readPackageJSON(configFilePath) as ConfigDataLibrary;
|
|
58
|
+
const tsConfig = await this.readTSConfig(configFilePath) as ConfigDataTypescript;
|
|
59
|
+
|
|
60
|
+
tsConfig.reflection ||= cliArgs.reflection;
|
|
61
|
+
|
|
62
|
+
// TODO replace with `cliArgs.logLevel`
|
|
63
|
+
configData.verbose = cliArgs.verbose || false;
|
|
64
|
+
configData.exclude = cliArgs.exclude || [];
|
|
65
|
+
|
|
66
|
+
merge(configData.library, pkg, configData.library);
|
|
67
|
+
merge(configData.typescript, tsConfig, configData.typescript);
|
|
68
|
+
merge(configData.esbuild, {
|
|
69
|
+
entryPoints: cliArgs.entryPoints,
|
|
70
|
+
outfile: cliArgs.outfile,
|
|
71
|
+
outdir: cliArgs.outdir,
|
|
72
|
+
logLevel: cliArgs.logLevel || 'warning'
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
if(configData.verbose) console.debug("configData", configData);
|
|
76
|
+
|
|
77
|
+
return configData;
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const APP_NAME = 'gjsify'
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import yargs from 'yargs'
|
|
3
|
+
import { hideBin } from 'yargs/helpers'
|
|
4
|
+
|
|
5
|
+
import { buildCommand as build } from './commands/index.js'
|
|
6
|
+
import { APP_NAME } from './constants.js'
|
|
7
|
+
|
|
8
|
+
void yargs(hideBin(process.argv))
|
|
9
|
+
.scriptName(APP_NAME)
|
|
10
|
+
.strict()
|
|
11
|
+
// .usage(Config.usage)
|
|
12
|
+
.command(build.command, build.description, build.builder, build.handler)
|
|
13
|
+
.demandCommand(1)
|
|
14
|
+
.help().argv
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { App } from '@gjsify/esbuild-plugin-gjsify';
|
|
2
|
+
|
|
3
|
+
export interface CliBuildOptions {
|
|
4
|
+
/**
|
|
5
|
+
* This is an array of files that each serve as an input to the bundling algorithm.
|
|
6
|
+
* @see https://esbuild.github.io/api/#entry-points
|
|
7
|
+
*/
|
|
8
|
+
entryPoints?: string[];
|
|
9
|
+
/** Switch on the verbose mode */
|
|
10
|
+
verbose?: boolean;
|
|
11
|
+
/** Use this if you want to build a application or test, the platforms node and deno are usually only used internally to build the tests for Gjsify */
|
|
12
|
+
app?: App;
|
|
13
|
+
/** Use this if you want to build a library for Gjsify */
|
|
14
|
+
library?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* This option sets the output file name for the build operation.
|
|
17
|
+
* This is only applicable if there is a single entry point.
|
|
18
|
+
* If there are multiple entry points, you must use the outdir option instead to specify an output directory.
|
|
19
|
+
* @see https://esbuild.github.io/api/#outfile
|
|
20
|
+
*/
|
|
21
|
+
outfile?: string;
|
|
22
|
+
/**
|
|
23
|
+
* This option sets the output directory for the build operation.
|
|
24
|
+
* @see https://esbuild.github.io/api/#outdir
|
|
25
|
+
*/
|
|
26
|
+
outdir?: string;
|
|
27
|
+
/** Enables TypeScript types on runtime using Deepkit's type compiler */
|
|
28
|
+
reflection?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The log level can be changed to prevent esbuild from printing warning and/or error messages to the terminal
|
|
31
|
+
* @see https://esbuild.github.io/api/#log-level
|
|
32
|
+
*/
|
|
33
|
+
logLevel: 'silent' | 'error' | 'warning' | 'info' | 'debug' | 'verbose';
|
|
34
|
+
/** An array of glob patterns to exclude matches and aliases */
|
|
35
|
+
exclude?: string[];
|
|
36
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ArgumentsCamelCase, MiddlewareFunction, BuilderCallback } from 'yargs';
|
|
2
|
+
|
|
3
|
+
export interface Command <T = any, U = T> {
|
|
4
|
+
command: string | ReadonlyArray<string>,
|
|
5
|
+
description: string,
|
|
6
|
+
builder?: BuilderCallback<T, U>,
|
|
7
|
+
handler?: (args: ArgumentsCamelCase<U>) => void | Promise<void>,
|
|
8
|
+
middlewares?: MiddlewareFunction[],
|
|
9
|
+
deprecated?: boolean | string,
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BuildOptions as EsbuildOptions} from 'esbuild';
|
|
2
|
+
import type { ConfigDataLibrary, ConfigDataTypescript } from './index.js';
|
|
3
|
+
|
|
4
|
+
export interface ConfigData {
|
|
5
|
+
/** Switch on the verbose mode */
|
|
6
|
+
verbose?: boolean;
|
|
7
|
+
esbuild?: EsbuildOptions;
|
|
8
|
+
library?: ConfigDataLibrary;
|
|
9
|
+
typescript?: ConfigDataTypescript;
|
|
10
|
+
/** An array of glob patterns to exclude matches and aliases */
|
|
11
|
+
exclude?: string[];
|
|
12
|
+
}
|
package/tsconfig.json
ADDED
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 gjsify
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
@gjsify/cli
|
|
2
|
-
===========
|
|
3
|
-
|
|
4
|
-
Command line tool for gjsify
|
|
5
|
-
|
|
6
|
-
[](https://oclif.io)
|
|
7
|
-
[](https://npmjs.org/package/@gjsify/cli)
|
|
8
|
-
[](https://npmjs.org/package/@gjsify/cli)
|
|
9
|
-
[](https://github.com/gjsify/cli/blob/master/package.json)
|
|
10
|
-
|
|
11
|
-
<!-- toc -->
|
|
12
|
-
* [Usage](#usage)
|
|
13
|
-
* [Commands](#commands)
|
|
14
|
-
* [CommonJS compatibility](#commonjs-compatibility)
|
|
15
|
-
<!-- tocstop -->
|
|
16
|
-
# Usage
|
|
17
|
-
<!-- usage -->
|
|
18
|
-
```sh-session
|
|
19
|
-
$ npm install -g @gjsify/cli
|
|
20
|
-
$ gjsify COMMAND
|
|
21
|
-
running command...
|
|
22
|
-
$ gjsify (-v|--version|version)
|
|
23
|
-
@gjsify/cli/0.0.1-b linux-x64 node-v12.14.1
|
|
24
|
-
$ gjsify --help [COMMAND]
|
|
25
|
-
USAGE
|
|
26
|
-
$ gjsify COMMAND
|
|
27
|
-
...
|
|
28
|
-
```
|
|
29
|
-
<!-- usagestop -->
|
|
30
|
-
# Commands
|
|
31
|
-
<!-- commands -->
|
|
32
|
-
* [`gjsify build [FILE]`](#gjsify-build-file)
|
|
33
|
-
* [`gjsify help [COMMAND]`](#gjsify-help-command)
|
|
34
|
-
|
|
35
|
-
## `gjsify build [FILE]`
|
|
36
|
-
|
|
37
|
-
describe the command here
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
USAGE
|
|
41
|
-
$ gjsify build [FILE]
|
|
42
|
-
|
|
43
|
-
OPTIONS
|
|
44
|
-
-b, --beautify Beautify build output
|
|
45
|
-
-h, --help show CLI help
|
|
46
|
-
-m, --minimize Minimize build output
|
|
47
|
-
-o, --outputFilename=outputFilename [default: index.js] File name of the output bundle
|
|
48
|
-
-p, --outputPath=outputPath [default: ./dist] Output destination path
|
|
49
|
-
--mangle Mangle build output
|
|
50
|
-
|
|
51
|
-
EXAMPLE
|
|
52
|
-
$ gjsify build ./src/hello.ts
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
_See code: [src/commands/build.ts](https://github.com/gjsify/cli/blob/v0.0.1-b/src/commands/build.ts)_
|
|
56
|
-
|
|
57
|
-
## `gjsify help [COMMAND]`
|
|
58
|
-
|
|
59
|
-
display help for gjsify
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
USAGE
|
|
63
|
-
$ gjsify help [COMMAND]
|
|
64
|
-
|
|
65
|
-
ARGUMENTS
|
|
66
|
-
COMMAND command to show help for
|
|
67
|
-
|
|
68
|
-
OPTIONS
|
|
69
|
-
--all see all commands in CLI
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.2.3/src/commands/help.ts)_
|
|
73
|
-
<!-- commandsstop -->
|
|
74
|
-
|
|
75
|
-
# CommonJS compatibility
|
|
76
|
-
|
|
77
|
-
Many [npm](https://www.npmjs.com/) modules that don't do IO will just work after being browserified. Others take more work.
|
|
78
|
-
|
|
79
|
-
When you require() any of these modules, you will get a gjs-specific shim:
|
package/bin/run
DELETED
package/bin/run.cmd
DELETED
package/lib/actions/init.d.ts
DELETED
|
File without changes
|
package/lib/actions/init.js
DELETED