create-next2d-app 1.2.6 → 2.0.1
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 +5 -24
- package/dist/index.d.ts +10 -5
- package/dist/index.js +92 -72
- package/package.json +14 -13
package/README.md
CHANGED
|
@@ -8,40 +8,21 @@ Create Next2D App
|
|
|
8
8
|
|
|
9
9
|
Create Next2D apps with no build configuration.
|
|
10
10
|
|
|
11
|
-
## Quick Start
|
|
11
|
+
## Quick Start (TypeScript)
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
|
-
npx create-next2d-app sample-app
|
|
14
|
+
npx create-next2d-app sample-app --template @next2d/framework-typescript-template
|
|
15
15
|
cd sample-app
|
|
16
16
|
npm start
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Quick Start (JavaScript)
|
|
20
20
|
|
|
21
|
-
* Starts the development server.
|
|
22
21
|
```sh
|
|
22
|
+
npx create-next2d-app sample-app --template @next2d/framework-template
|
|
23
|
+
cd sample-app
|
|
23
24
|
npm start
|
|
24
25
|
```
|
|
25
26
|
|
|
26
|
-
* Generate the necessary View and ViewModel classes from the routing JSON file.
|
|
27
|
-
```sh
|
|
28
|
-
npm run generate
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
* Start the emulator for each platform.
|
|
32
|
-
```sh
|
|
33
|
-
npm run [ios|android|windows|macos] -- --env prd
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
* Export a production version for each platform.
|
|
37
|
-
```sh
|
|
38
|
-
npm run build -- --platform [windows|macos|web] --env prd
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
* Starts the test runner.
|
|
42
|
-
```sh
|
|
43
|
-
npm test
|
|
44
|
-
```
|
|
45
|
-
|
|
46
27
|
## License
|
|
47
28
|
This project is licensed under the [MIT License](https://opensource.org/licenses/MIT) - see the [LICENSE](LICENSE) file for details.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
declare const
|
|
3
|
-
declare const chalk: any;
|
|
2
|
+
declare const pc: any;
|
|
4
3
|
declare const commander: any;
|
|
4
|
+
declare const packageJson: any;
|
|
5
|
+
declare const path: any;
|
|
6
|
+
declare const validateProjectName: any;
|
|
5
7
|
declare const execSync: any;
|
|
6
8
|
declare const fs: any;
|
|
7
9
|
declare const os: any;
|
|
8
|
-
declare const path: any;
|
|
9
10
|
declare const semver: any;
|
|
10
11
|
declare const spawn: any;
|
|
11
|
-
declare const
|
|
12
|
-
declare const
|
|
12
|
+
declare const recommendeVersion: number;
|
|
13
|
+
declare const version: string;
|
|
14
|
+
/**
|
|
15
|
+
* @type {string}
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
13
18
|
declare let projectName: string;
|
|
14
19
|
/**
|
|
15
20
|
* @param {string} app_name
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
const
|
|
4
|
-
if (15 > version) {
|
|
5
|
-
console.error("You are running Node Version:" + version + ".\n" +
|
|
6
|
-
"Create Next2d App requires Node 15 or higher. \n" +
|
|
7
|
-
"Please update your version of Node.");
|
|
8
|
-
process.exit(1);
|
|
9
|
-
}
|
|
10
|
-
const chalk = require("chalk");
|
|
3
|
+
const pc = require("picocolors");
|
|
11
4
|
const commander = require("commander");
|
|
5
|
+
const packageJson = require("../package.json");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
const validateProjectName = require("validate-npm-package-name");
|
|
12
8
|
const execSync = require("child_process").execSync;
|
|
13
9
|
const fs = require("fs-extra");
|
|
14
10
|
const os = require("os");
|
|
15
|
-
const path = require("path");
|
|
16
11
|
const semver = require("semver");
|
|
17
12
|
const spawn = require("cross-spawn");
|
|
18
|
-
const
|
|
19
|
-
const
|
|
13
|
+
const recommendeVersion = 18;
|
|
14
|
+
const version = process.versions.node;
|
|
15
|
+
if (recommendeVersion > parseInt(version.split(".")[0])) {
|
|
16
|
+
pc.red(`You are running Node Version:${version}.
|
|
17
|
+
View Generator requires Node ${recommendeVersion} or higher.
|
|
18
|
+
Please update your version of Node.`);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @type {string}
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
20
25
|
let projectName = "";
|
|
21
26
|
/**
|
|
22
27
|
* @param {string} app_name
|
|
@@ -27,14 +32,14 @@ let projectName = "";
|
|
|
27
32
|
const checkAppName = (app_name) => {
|
|
28
33
|
const validationResult = validateProjectName(app_name);
|
|
29
34
|
if (!validationResult.validForNewPackages) {
|
|
30
|
-
console.error(
|
|
35
|
+
console.error(pc.red(`Cannot create a project named ${pc.green(`"${app_name}"`)} because of npm naming restrictions:\n`));
|
|
31
36
|
[
|
|
32
37
|
...validationResult.errors || [],
|
|
33
38
|
...validationResult.warnings || []
|
|
34
39
|
].forEach((error) => {
|
|
35
|
-
console.error(
|
|
40
|
+
console.error(pc.red(` * ${error}`));
|
|
36
41
|
});
|
|
37
|
-
console.error(
|
|
42
|
+
console.error(pc.red("\nPlease choose a different project name."));
|
|
38
43
|
process.exit(1);
|
|
39
44
|
}
|
|
40
45
|
const dependencies = [
|
|
@@ -43,10 +48,10 @@ const checkAppName = (app_name) => {
|
|
|
43
48
|
"next2d-framework"
|
|
44
49
|
].sort();
|
|
45
50
|
if (dependencies.includes(app_name)) {
|
|
46
|
-
console.error(
|
|
51
|
+
console.error(pc.red(`Cannot create a project named ${pc.green(`"${app_name}"`)} because a dependency with the same name exists.\n` +
|
|
47
52
|
"Due to the way npm works, the following names are not allowed:\n\n") +
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
pc.cyan(dependencies.map((depName) => ` ${depName}`).join("\n")) +
|
|
54
|
+
pc.red("\n\nPlease choose a different project name."));
|
|
50
55
|
process.exit(1);
|
|
51
56
|
}
|
|
52
57
|
};
|
|
@@ -77,16 +82,16 @@ const checkThatNpmCanReadCwd = () => {
|
|
|
77
82
|
if (npmCWD === cwd) {
|
|
78
83
|
return true;
|
|
79
84
|
}
|
|
80
|
-
console.error(
|
|
81
|
-
`The current directory is: ${
|
|
82
|
-
`However, a newly started npm process runs in: ${
|
|
85
|
+
console.error(pc.red("Could not start an npm process in the right directory.\n\n" +
|
|
86
|
+
`The current directory is: ${pc.bold(cwd)}\n` +
|
|
87
|
+
`However, a newly started npm process runs in: ${pc.bold(npmCWD)}\n\n` +
|
|
83
88
|
"This is probably caused by a misconfigured system terminal shell."));
|
|
84
89
|
if (process.platform === "win32") {
|
|
85
|
-
console.error(
|
|
86
|
-
` ${
|
|
87
|
-
` ${
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
console.error(pc.red("On Windows, this can usually be fixed by running:\n\n") +
|
|
91
|
+
` ${pc.cyan("reg")} delete "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun /f\n` +
|
|
92
|
+
` ${pc.cyan("reg")} delete "HKLM\\Software\\Microsoft\\Command Processor" /v AutoRun /f\n\n` +
|
|
93
|
+
pc.red("Try to run the above two lines in the terminal.\n") +
|
|
94
|
+
pc.red("To learn more about this problem, read: https://blogs.msdn.microsoft.com/oldnewthing/20071121-00/?p=24433/"));
|
|
90
95
|
}
|
|
91
96
|
return false;
|
|
92
97
|
};
|
|
@@ -124,8 +129,7 @@ const install = (root, app_name, template, dependencies) => {
|
|
|
124
129
|
const args = [
|
|
125
130
|
"install",
|
|
126
131
|
"--no-audit",
|
|
127
|
-
"--save",
|
|
128
|
-
"--save-exact",
|
|
132
|
+
"--save-dev",
|
|
129
133
|
"--loglevel",
|
|
130
134
|
"error",
|
|
131
135
|
template
|
|
@@ -139,7 +143,7 @@ const install = (root, app_name, template, dependencies) => {
|
|
|
139
143
|
}
|
|
140
144
|
else {
|
|
141
145
|
console.log();
|
|
142
|
-
console.log(`Installing template: ${
|
|
146
|
+
console.log(`Installing template: ${pc.green(template)}`);
|
|
143
147
|
const templatePath = path.dirname(require.resolve(`${template}/package.json`, { "paths": [root] }));
|
|
144
148
|
const templateJsonPath = path.join(templatePath, "template.json");
|
|
145
149
|
let templateJson = {};
|
|
@@ -170,14 +174,13 @@ const install = (root, app_name, template, dependencies) => {
|
|
|
170
174
|
fs.copySync(templateDir, root);
|
|
171
175
|
}
|
|
172
176
|
else {
|
|
173
|
-
console.error(`Could not locate supplied template: ${
|
|
177
|
+
console.error(`Could not locate supplied template: ${pc.green(templateDir)}`);
|
|
174
178
|
return;
|
|
175
179
|
}
|
|
176
180
|
const args = [
|
|
177
181
|
"uninstall",
|
|
178
182
|
"--no-audit",
|
|
179
|
-
"--save",
|
|
180
|
-
"--save-exact",
|
|
183
|
+
"--save-dev",
|
|
181
184
|
"--loglevel",
|
|
182
185
|
"error",
|
|
183
186
|
template
|
|
@@ -201,8 +204,7 @@ const install = (root, app_name, template, dependencies) => {
|
|
|
201
204
|
const args = [
|
|
202
205
|
"install",
|
|
203
206
|
"--no-audit",
|
|
204
|
-
"--save",
|
|
205
|
-
"--save-exact",
|
|
207
|
+
"--save-dev",
|
|
206
208
|
"--loglevel",
|
|
207
209
|
"error"
|
|
208
210
|
].concat(dependencies);
|
|
@@ -216,28 +218,28 @@ const install = (root, app_name, template, dependencies) => {
|
|
|
216
218
|
}
|
|
217
219
|
else {
|
|
218
220
|
console.log();
|
|
219
|
-
console.log(`Success! Created ${
|
|
221
|
+
console.log(`Success! Created ${pc.green(app_name)} at ${pc.green(root)}`);
|
|
220
222
|
console.log();
|
|
221
223
|
console.log("you can run several commands:");
|
|
222
224
|
console.log();
|
|
223
|
-
console.log(` ${
|
|
225
|
+
console.log(` ${pc.green("npm start")}`);
|
|
224
226
|
console.log(" Starts the development server.");
|
|
225
227
|
console.log();
|
|
226
|
-
console.log(` ${
|
|
228
|
+
console.log(` ${pc.green("npm run generate")}`);
|
|
227
229
|
console.log(" Generate the necessary View and ViewModel classes from the routing JSON file.");
|
|
228
230
|
console.log();
|
|
229
|
-
console.log(` ${
|
|
231
|
+
console.log(` ${pc.green("npm run [ios|android|windows|macos] -- --env prd")}`);
|
|
230
232
|
console.log(" Start the emulator for each platform.");
|
|
231
233
|
console.log();
|
|
232
|
-
console.log(` ${
|
|
234
|
+
console.log(` ${pc.green("npm run build -- --platform [windows|macos|web] --env prd")}`);
|
|
233
235
|
console.log(" Export a production version for each platform.");
|
|
234
236
|
console.log();
|
|
235
|
-
console.log(` ${
|
|
237
|
+
console.log(` ${pc.green("npm test")}`);
|
|
236
238
|
console.log(" Starts the test runner.");
|
|
237
239
|
console.log();
|
|
238
240
|
console.log("We suggest that you begin by typing:");
|
|
239
|
-
console.log(` ${
|
|
240
|
-
console.log(` ${
|
|
241
|
+
console.log(` ${pc.green("cd")} ${app_name}`);
|
|
242
|
+
console.log(` ${pc.green("npm start")}`);
|
|
241
243
|
console.log();
|
|
242
244
|
}
|
|
243
245
|
});
|
|
@@ -256,23 +258,26 @@ const createApp = (app_name, template = "@next2d/framework-template") => {
|
|
|
256
258
|
checkAppName(appName);
|
|
257
259
|
fs.ensureDirSync(app_name);
|
|
258
260
|
console.log();
|
|
259
|
-
console.log(`Creating a new Next2D app in ${
|
|
261
|
+
console.log(`Creating a new Next2D app in ${pc.green(root)}.`);
|
|
260
262
|
console.log();
|
|
261
263
|
fs.writeFileSync(path.join(root, "package.json"), JSON.stringify({
|
|
262
264
|
"name": appName,
|
|
263
265
|
"description": `Details of ${appName}`,
|
|
264
266
|
"version": "0.0.1",
|
|
265
267
|
"private": true,
|
|
266
|
-
"
|
|
268
|
+
"type": "module",
|
|
267
269
|
"scripts": {
|
|
268
|
-
"start": "
|
|
269
|
-
"ios": "npx @next2d/builder
|
|
270
|
-
"android": "npx @next2d/builder
|
|
271
|
-
"macos": "npx @next2d/builder --platform macos --
|
|
272
|
-
"windows": "npx @next2d/builder --platform windows --
|
|
273
|
-
"
|
|
274
|
-
"
|
|
275
|
-
"
|
|
270
|
+
"start": "vite",
|
|
271
|
+
"preview:ios": "npx @next2d/builder --platform ios --preview",
|
|
272
|
+
"preview:android": "npx @next2d/builder --platform android --preview",
|
|
273
|
+
"preview:macos": "npx @next2d/builder --platform macos --preview",
|
|
274
|
+
"preview:windows": "npx @next2d/builder --platform windows --preview",
|
|
275
|
+
"preview:linux": "npx @next2d/builder --platform linux --preview",
|
|
276
|
+
"build:steam:windows": "npx @next2d/builder --platform steam:windows --env prd",
|
|
277
|
+
"build:steam:macos": "npx @next2d/builder --platform steam:macos --env prd",
|
|
278
|
+
"build:steam:linux": "npx @next2d/builder --platform steam:linux --env prd",
|
|
279
|
+
"build:web": "npx @next2d/builder --platform web --env prd",
|
|
280
|
+
"test": "npx vitest",
|
|
276
281
|
"generate": "npx @next2d/view-generator"
|
|
277
282
|
}
|
|
278
283
|
}, null, 2) + os.EOL);
|
|
@@ -283,32 +288,46 @@ const createApp = (app_name, template = "@next2d/framework-template") => {
|
|
|
283
288
|
const npmInfo = checkNpmVersion();
|
|
284
289
|
if (!npmInfo.hasMinNpm) {
|
|
285
290
|
if (npmInfo.npmVersion) {
|
|
286
|
-
console.log(
|
|
291
|
+
console.log(pc.yellow(`You are using npm ${npmInfo.npmVersion} so the project will be bootstrapped with an old unsupported version of tools.\n\n` +
|
|
287
292
|
"Please update to npm 6 or higher for a better, fully supported experience.\n"));
|
|
288
293
|
}
|
|
289
294
|
}
|
|
290
295
|
const ignoreList = [
|
|
291
|
-
"
|
|
292
|
-
"
|
|
293
|
-
"
|
|
294
|
-
".DS_Store",
|
|
295
|
-
".idea",
|
|
296
|
-
"Thumbs.db",
|
|
296
|
+
"# Logs",
|
|
297
|
+
"logs",
|
|
298
|
+
"*.log",
|
|
297
299
|
"npm-debug.log*",
|
|
298
300
|
"yarn-debug.log*",
|
|
299
301
|
"yarn-error.log*",
|
|
300
|
-
"
|
|
301
|
-
"
|
|
302
|
+
"pnpm-debug.log*",
|
|
303
|
+
"lerna-debug.log*",
|
|
304
|
+
"node_modules",
|
|
305
|
+
"dist",
|
|
306
|
+
"dist-ssr",
|
|
307
|
+
"*.local",
|
|
308
|
+
"# Editor directories and files",
|
|
309
|
+
".vscode/*",
|
|
310
|
+
"!.vscode/extensions.json",
|
|
311
|
+
".idea",
|
|
312
|
+
".DS_Store",
|
|
313
|
+
"*.suo",
|
|
314
|
+
"*.ntvs*",
|
|
315
|
+
"*.njsproj",
|
|
316
|
+
"*.sln",
|
|
317
|
+
"*.sw?",
|
|
318
|
+
"src/config/Config.*",
|
|
319
|
+
"src/Packages.*",
|
|
302
320
|
"electron.index.json"
|
|
303
321
|
];
|
|
304
322
|
fs.writeFileSync(path.join(root, ".gitignore"), ignoreList.join(os.EOL));
|
|
305
323
|
install(root, appName, template, [
|
|
324
|
+
"@next2d/player",
|
|
306
325
|
"@next2d/framework",
|
|
307
|
-
"@next2d/
|
|
326
|
+
"@next2d/vite-auto-loader-plugin",
|
|
327
|
+
"jsdom",
|
|
328
|
+
"vite",
|
|
329
|
+
"vitest",
|
|
308
330
|
"electron",
|
|
309
|
-
"webpack",
|
|
310
|
-
"webpack-cli",
|
|
311
|
-
"webpack-dev-server",
|
|
312
331
|
"@capacitor/cli",
|
|
313
332
|
"@capacitor/core",
|
|
314
333
|
"@capacitor/ios",
|
|
@@ -324,28 +343,29 @@ const execute = () => {
|
|
|
324
343
|
const program = new commander.Command(packageJson.name)
|
|
325
344
|
.version(packageJson.version)
|
|
326
345
|
.arguments("<project-directory>")
|
|
327
|
-
.usage(`${
|
|
346
|
+
.usage(`${pc.green("<project-directory>")} [options]`)
|
|
328
347
|
.action((name) => { projectName = name; })
|
|
329
348
|
.option("--info", "print environment debug info")
|
|
330
349
|
.option("--template <path-to-template>", "specify a template for the created project")
|
|
331
|
-
.on("--help", () => {
|
|
350
|
+
.on("-h, --help", () => {
|
|
332
351
|
console.log();
|
|
333
|
-
console.log(` A custom ${
|
|
334
|
-
console.log(` - a custom template published on npm default: ${
|
|
352
|
+
console.log(` A custom ${pc.cyan("--template")} can be one of:`);
|
|
353
|
+
console.log(` - a custom template published on npm default: ${pc.green("@next2d/framework-template")}`);
|
|
335
354
|
console.log();
|
|
336
355
|
console.log(" If you have any problems, do not hesitate to file an issue:");
|
|
337
|
-
console.log(` ${
|
|
356
|
+
console.log(` ${pc.cyan("https://github.com/Next2D/create-next2d-app/issues/new")}`);
|
|
338
357
|
console.log();
|
|
339
358
|
})
|
|
340
359
|
.parse(process.argv);
|
|
341
360
|
if (typeof projectName === "undefined") {
|
|
342
361
|
console.error("Please specify the project directory:");
|
|
343
|
-
console.log(` npx ${
|
|
362
|
+
console.log(` npx ${pc.cyan(program.name())} ${pc.green("<project-directory>")}`);
|
|
344
363
|
console.log();
|
|
345
364
|
console.log("For example:");
|
|
346
|
-
console.log(` npx ${
|
|
365
|
+
console.log(` npx ${pc.cyan(program.name())} ${pc.green("my-next2d-app")}`);
|
|
347
366
|
process.exit(1);
|
|
348
367
|
}
|
|
349
|
-
|
|
368
|
+
const options = program.opts();
|
|
369
|
+
createApp(projectName, options.template);
|
|
350
370
|
};
|
|
351
371
|
execute();
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-next2d-app",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Create Next2D apps with no build configuration.",
|
|
5
5
|
"author": "Toshiyuki Ienaga<ienaga@tvon.jp>",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
7
9
|
"homepage": "https://next2d.app",
|
|
8
10
|
"bugs": "https://github.com/Next2D/create-next2d-app/issues",
|
|
9
11
|
"keywords": [
|
|
@@ -11,14 +13,13 @@
|
|
|
11
13
|
"create-next2d-app"
|
|
12
14
|
],
|
|
13
15
|
"scripts": {
|
|
14
|
-
"lint": "eslint src
|
|
15
|
-
"
|
|
16
|
+
"lint": "eslint src/index.ts",
|
|
17
|
+
"publish": "tsc"
|
|
16
18
|
},
|
|
17
19
|
"repository": {
|
|
18
20
|
"type": "git",
|
|
19
21
|
"url": "git+https://github.com/Next2D/create-next2d-app.git"
|
|
20
22
|
},
|
|
21
|
-
"types": "dist",
|
|
22
23
|
"files": [
|
|
23
24
|
"dist"
|
|
24
25
|
],
|
|
@@ -26,19 +27,19 @@
|
|
|
26
27
|
"create-next2d-app": "dist/index.js"
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"
|
|
30
|
-
"
|
|
30
|
+
"@types/node": "^20.9.0",
|
|
31
|
+
"picocolors": "^1.0.0",
|
|
32
|
+
"commander": "11.1.0",
|
|
31
33
|
"cross-spawn": "7.0.3",
|
|
32
|
-
"fs-extra": "
|
|
33
|
-
"semver": "7.5.
|
|
34
|
+
"fs-extra": "11.1.1",
|
|
35
|
+
"semver": "7.5.4",
|
|
34
36
|
"tar-pack": "3.4.1",
|
|
35
37
|
"validate-npm-package-name": "5.0.0"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@typescript-eslint/
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"typescript": "^5.1.6"
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^6.10.0",
|
|
41
|
+
"@typescript-eslint/parser": "^6.10.0",
|
|
42
|
+
"eslint": "^8.53.0",
|
|
43
|
+
"typescript": "^5.2.2"
|
|
43
44
|
}
|
|
44
45
|
}
|