@galacean/cli 0.0.1-0

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/README.md ADDED
@@ -0,0 +1,66 @@
1
+ Galacean CLI
2
+ =================
3
+
4
+ The all-in-one Galacean CLI that helps you build Galacean applications.
5
+
6
+ <!-- toc -->
7
+ * [Usage](#usage)
8
+ * [Commands](#commands)
9
+ <!-- tocstop -->
10
+ # Usage
11
+ <!-- usage -->
12
+ ```sh-session
13
+ $ npm install -g @galacean/cli
14
+ $ galacean COMMAND
15
+ running command...
16
+ $ galacean (--version)
17
+ @galacean/cli/0.0.1-0 darwin-x64 node-v16.17.0
18
+ $ galacean --help [COMMAND]
19
+ USAGE
20
+ $ galacean COMMAND
21
+ ...
22
+ ```
23
+ <!-- usagestop -->
24
+ # Commands
25
+ <!-- commands -->
26
+ * [`galacean generate NAME`](#galacean-generate-name)
27
+ * [`galacean help [COMMANDS]`](#galacean-help-commands)
28
+
29
+ ## `galacean generate NAME`
30
+
31
+ generate a new Galacean Editor plugin
32
+
33
+ ```
34
+ USAGE
35
+ $ galacean generate NAME
36
+
37
+ ARGUMENTS
38
+ NAME directory name of new plugin
39
+
40
+ DESCRIPTION
41
+ generate a new Galacean Editor plugin
42
+ This will clone the specific folder in 'galacean/galacean-editor-plugin-examples' and update package properties
43
+ ```
44
+
45
+ _See code: [dist/commands/generate.ts](https://github.com/galacean/cli/blob/v0.0.1-0/dist/commands/generate.ts)_
46
+
47
+ ## `galacean help [COMMANDS]`
48
+
49
+ Display help for galacean.
50
+
51
+ ```
52
+ USAGE
53
+ $ galacean help [COMMANDS] [-n]
54
+
55
+ ARGUMENTS
56
+ COMMANDS Command to show help for.
57
+
58
+ FLAGS
59
+ -n, --nested-commands Include all nested commands in the output.
60
+
61
+ DESCRIPTION
62
+ Display help for galacean.
63
+ ```
64
+
65
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.14/src/commands/help.ts)_
66
+ <!-- commandsstop -->
package/bin/dev ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+
3
+ const oclif = require('@oclif/core')
4
+
5
+ const path = require('path')
6
+ const project = path.join(__dirname, '..', 'tsconfig.json')
7
+
8
+ // In dev mode -> use ts-node and dev plugins
9
+ process.env.NODE_ENV = 'development'
10
+
11
+ require('ts-node').register({ project })
12
+
13
+ // In dev mode, always show stack traces
14
+ oclif.settings.debug = true;
15
+
16
+ // Start the CLI
17
+ oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
package/bin/dev.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\dev" %*
package/bin/run ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ const oclif = require('@oclif/core')
4
+
5
+ oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'))
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\run" %*
@@ -0,0 +1,10 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Generate extends Command {
3
+ static description: string;
4
+ static flags: {};
5
+ static args: {
6
+ name: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
7
+ };
8
+ protected generate(type?: string, generatorOptions?: Record<string, unknown>): Promise<void>;
9
+ run(): Promise<void>;
10
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const yeoman_environment_1 = require("yeoman-environment");
5
+ class Generate extends core_1.Command {
6
+ async generate(type = 'plugin', generatorOptions = {}) {
7
+ const env = (0, yeoman_environment_1.createEnv)();
8
+ env.register(require.resolve(`../generators/${type}`), `galacean:${type}`);
9
+ await env.run(`galacean:${type}`, generatorOptions);
10
+ }
11
+ async run() {
12
+ const { args } = await this.parse(Generate);
13
+ await this.generate('plugin', { name: args.name, force: true });
14
+ }
15
+ }
16
+ exports.default = Generate;
17
+ Generate.description = `generate a new Galacean Editor plugin
18
+ This will clone the specific folder in 'galacean/galacean-editor-plugin-examples' and update package properties`;
19
+ Generate.flags = {};
20
+ Generate.args = {
21
+ name: core_1.Args.string({ required: true, description: 'directory name of new plugin' }),
22
+ };
@@ -0,0 +1,33 @@
1
+ import * as Generator from 'yeoman-generator';
2
+ export default class PluginGenerator extends Generator {
3
+ options: {
4
+ force: boolean;
5
+ };
6
+ exampleRepoUrl: string;
7
+ name: string;
8
+ pjson: any;
9
+ githubUser: string;
10
+ answers: {
11
+ name: string;
12
+ bin: string;
13
+ description: string;
14
+ version: string;
15
+ github: {
16
+ repo: string;
17
+ user: string;
18
+ };
19
+ author: string;
20
+ files: string;
21
+ license: string;
22
+ galacean: string;
23
+ pkg: string;
24
+ typescript: boolean;
25
+ eslint: boolean;
26
+ };
27
+ repository?: string;
28
+ constructor(args: string | string[], opts: Generator.GeneratorOptions);
29
+ prompting(): Promise<void>;
30
+ writing(): void;
31
+ end(): void;
32
+ private _gitignore;
33
+ }
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const child_process_1 = require("child_process");
4
+ const fs = require("fs");
5
+ const _ = require("lodash");
6
+ const path = require("path");
7
+ const nodeDebug = require("debug");
8
+ const Generator = require("yeoman-generator");
9
+ const debug = nodeDebug('galacean-plugin-generator');
10
+ const { version } = require('../../package.json');
11
+ class PluginGenerator extends Generator {
12
+ constructor(args, opts) {
13
+ super(args, opts);
14
+ this.exampleRepoUrl = 'https://github.com/galacean/galacean-editor-plugin-examples';
15
+ this.githubUser = '';
16
+ this.name = opts.name;
17
+ this.options.force = opts.force;
18
+ }
19
+ async prompting() {
20
+ this.log(`Galacean Editor Plugin Generator. version: ${version}`);
21
+ const { pluginType } = await this.prompt([
22
+ {
23
+ type: 'list',
24
+ name: 'pluginType',
25
+ message: 'Select a plugin type',
26
+ choices: [
27
+ { name: 'Basic', value: 'basic' },
28
+ { name: 'React', value: 'react' },
29
+ ],
30
+ default: 'blank',
31
+ },
32
+ ]);
33
+ const targetDir = path.resolve(this.name);
34
+ (0, child_process_1.execSync)(`git clone ${this.exampleRepoUrl} "${targetDir}" --depth=1`);
35
+ for (const f of fs.readdirSync(path.resolve(this.name)).filter(file => file !== pluginType)) {
36
+ const p = `${path.resolve(this.name, f)}`;
37
+ this.log(p);
38
+ fs.rmSync(p, { recursive: true, force: true });
39
+ }
40
+ (0, child_process_1.execSync)(`mv ${path.resolve(this.name, pluginType, '*')} ${path.resolve(this.name)}`);
41
+ fs.rmSync(`${path.resolve(this.name, pluginType)}`, { recursive: true, force: true });
42
+ this.destinationRoot(path.resolve(this.name));
43
+ this.env.cwd = this.destinationPath();
44
+ try {
45
+ this.githubUser = await this.user.github.username();
46
+ }
47
+ catch (error) {
48
+ debug(error);
49
+ }
50
+ this.pjson = {
51
+ name: '',
52
+ version: '',
53
+ description: '',
54
+ author: '',
55
+ bin: {},
56
+ homepage: '',
57
+ license: '',
58
+ main: '',
59
+ repository: '',
60
+ files: [],
61
+ dependencies: {},
62
+ devDependencies: {},
63
+ galacean: '',
64
+ scripts: {},
65
+ engines: {},
66
+ ...this.fs.readJSON(path.join(this.env.cwd, 'package.json'), {}),
67
+ };
68
+ let repository = this.destinationRoot().split(path.sep).slice(-2).join('/');
69
+ if (this.githubUser) {
70
+ repository = `${this.githubUser}/${repository.split('/')[1]}`;
71
+ }
72
+ const defaults = {
73
+ ...this.pjson,
74
+ name: (this.name || this.determineAppname()).replace(/ /g, '-'),
75
+ version: '0.0.0',
76
+ license: 'MIT',
77
+ author: this.githubUser ? `${this.user.git.name()} @${this.githubUser}` : this.user.git.name(),
78
+ dependencies: {},
79
+ repository,
80
+ engines: {
81
+ node: '>=12.0.0',
82
+ ...this.pjson.engines,
83
+ },
84
+ };
85
+ this.repository = defaults.repository;
86
+ if (this.repository && this.repository.url) {
87
+ this.repository = this.repository.url;
88
+ }
89
+ this.answers = await this.prompt([
90
+ {
91
+ type: 'input',
92
+ name: 'name',
93
+ message: 'plugin package name',
94
+ default: defaults.name,
95
+ },
96
+ {
97
+ type: 'input',
98
+ name: 'description',
99
+ message: 'description',
100
+ default: defaults.description,
101
+ },
102
+ {
103
+ type: 'input',
104
+ name: 'author',
105
+ message: 'author',
106
+ default: defaults.author,
107
+ },
108
+ {
109
+ type: 'input',
110
+ name: 'galacean',
111
+ message: 'The minimum version of Galacean that this plugin supports',
112
+ default: defaults.galacean,
113
+ },
114
+ {
115
+ type: 'input',
116
+ name: 'license',
117
+ message: 'license',
118
+ default: defaults.license,
119
+ },
120
+ {
121
+ type: 'input',
122
+ name: 'github.user',
123
+ message: 'Who is the GitHub owner of repository (https://github.com/OWNER/repo)',
124
+ default: repository.split('/').slice(0, -1).pop(),
125
+ },
126
+ {
127
+ type: 'input',
128
+ name: 'github.repo',
129
+ message: 'What is the GitHub name of repository (https://github.com/owner/REPO)',
130
+ default: (answers) => (answers.name || this.pjson.repository || this.pjson.name).split('/').pop(),
131
+ },
132
+ ]);
133
+ debug(this.answers);
134
+ this.pjson.name = this.answers.name || defaults.name;
135
+ this.pjson.description = this.answers.description || defaults.description;
136
+ this.pjson.version = this.answers.version || defaults.version;
137
+ this.pjson.engines.node = defaults.engines.node;
138
+ this.pjson.author = this.answers.author || defaults.author;
139
+ this.pjson.files = this.answers.files || defaults.files || '/lib';
140
+ this.pjson.license = this.answers.license || defaults.license;
141
+ // eslint-disable-next-line no-multi-assign
142
+ this.repository = this.pjson.repository = this.answers.github ? `${this.answers.github.user}/${this.answers.github.repo}` : defaults.repository;
143
+ this.pjson.homepage = `https://github.com/${this.repository}`;
144
+ this.pjson.bugs = `https://github.com/${this.repository}/issues`;
145
+ }
146
+ writing() {
147
+ this.pjson.files = _.uniq((this.pjson.files || []).sort());
148
+ this.fs.writeJSON(this.destinationPath('./package.json'), this.pjson);
149
+ this.fs.write(this.destinationPath('.gitignore'), this._gitignore());
150
+ this.fs.delete(this.destinationPath('LICENSE'));
151
+ }
152
+ end() {
153
+ this.spawnCommandSync(this.env.options.nodePackageManager, ['run', 'build'], { cwd: this.env.cwd });
154
+ this.log(`\nCreated ${this.pjson.name} in ${this.destinationRoot()}`);
155
+ }
156
+ _gitignore() {
157
+ const existing = this.fs.exists(this.destinationPath('.gitignore')) ? this.fs.read(this.destinationPath('.gitignore')).split('\n') : [];
158
+ return _([
159
+ '*-debug.log',
160
+ '*-error.log',
161
+ 'node_modules',
162
+ '/tmp',
163
+ '/dist',
164
+ '/lib',
165
+ ])
166
+ .concat(existing)
167
+ .compact()
168
+ .uniq()
169
+ .sort()
170
+ .join('\n') + '\n';
171
+ }
172
+ }
173
+ exports.default = PluginGenerator;
@@ -0,0 +1 @@
1
+ export { run } from '@oclif/core';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.run = void 0;
4
+ var core_1 = require("@oclif/core");
5
+ Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
@@ -0,0 +1,22 @@
1
+ {
2
+ "version": "0.0.1-0",
3
+ "commands": {
4
+ "generate": {
5
+ "id": "generate",
6
+ "description": "generate a new Galacean Editor plugin\nThis will clone the specific folder in 'galacean/galacean-editor-plugin-examples' and update package properties",
7
+ "strict": true,
8
+ "pluginName": "@galacean/cli",
9
+ "pluginAlias": "@galacean/cli",
10
+ "pluginType": "core",
11
+ "aliases": [],
12
+ "flags": {},
13
+ "args": {
14
+ "name": {
15
+ "name": "name",
16
+ "description": "directory name of new plugin",
17
+ "required": true
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@galacean/cli",
3
+ "version": "0.0.1-0",
4
+ "description": "All-in-one cli tool that help you using Galacean Framework.",
5
+ "author": "Kbscript @MrKou47",
6
+ "bin": {
7
+ "galacean": "./bin/run"
8
+ },
9
+ "homepage": "https://github.com/galacean/cli",
10
+ "license": "MIT",
11
+ "main": "dist/index.js",
12
+ "repository": "galacean/cli",
13
+ "files": [
14
+ "/bin",
15
+ "/dist",
16
+ "/npm-shrinkwrap.json",
17
+ "/oclif.manifest.json"
18
+ ],
19
+ "dependencies": {
20
+ "@oclif/core": "^2",
21
+ "@oclif/plugin-help": "^5",
22
+ "@oclif/plugin-plugins": "^2.4.7",
23
+ "yeoman-environment": "^3.19.3",
24
+ "yeoman-generator": "^5.9.0"
25
+ },
26
+ "devDependencies": {
27
+ "@oclif/test": "^2.4.0",
28
+ "@types/chai": "^4",
29
+ "@types/mocha": "^9.0.0",
30
+ "@types/node": "^16.18.39",
31
+ "@types/yeoman-generator": "^5.2.11",
32
+ "chai": "^4",
33
+ "eslint": "^7.32.0",
34
+ "eslint-config-oclif": "^4",
35
+ "eslint-config-oclif-typescript": "^1.0.3",
36
+ "mocha": "^9",
37
+ "oclif": "^3.10.0",
38
+ "shx": "^0.3.3",
39
+ "ts-node": "^10.9.1",
40
+ "tslib": "^2.6.1",
41
+ "typescript": "^4.9.5"
42
+ },
43
+ "oclif": {
44
+ "bin": "galacean",
45
+ "dirname": "galacean",
46
+ "commands": "./dist/commands",
47
+ "plugins": [
48
+ "@oclif/plugin-help"
49
+ ]
50
+ },
51
+ "scripts": {
52
+ "build": "shx rm -rf dist && tsc -b",
53
+ "lint": "eslint . --ext .ts --config .eslintrc",
54
+ "postpack": "shx rm -f oclif.manifest.json",
55
+ "posttest": "npm run lint",
56
+ "prepack": "npm run build && oclif manifest && oclif readme",
57
+ "test": "mocha --forbid-only \"test/**/*.test.ts\"",
58
+ "version": "oclif readme && git add README.md"
59
+ },
60
+ "engines": {
61
+ "node": ">=12.0.0"
62
+ },
63
+ "bugs": "https://github.com/galacean/cli/issues",
64
+ "keywords": [
65
+ "galacean",
66
+ "cli",
67
+ "plugin"
68
+ ],
69
+ "types": "dist/index.d.ts",
70
+ "publishConfig": {
71
+ "registry": "https://registry.npmjs.org"
72
+ }
73
+ }