create-next2d-app 1.2.5 → 2.0.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 +16 -4
- package/dist/index.d.ts +10 -5
- package/dist/index.js +91 -68
- package/package.json +17 -16
package/README.md
CHANGED
|
@@ -8,10 +8,18 @@ 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
|
+
cd sample-app
|
|
16
|
+
npm start
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start (JavaScript)
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npx create-next2d-app sample-app --template @next2d/framework-template
|
|
15
23
|
cd sample-app
|
|
16
24
|
npm start
|
|
17
25
|
```
|
|
@@ -30,12 +38,16 @@ npm run generate
|
|
|
30
38
|
|
|
31
39
|
* Start the emulator for each platform.
|
|
32
40
|
```sh
|
|
33
|
-
npm run
|
|
41
|
+
npm run preview:(ios|android|windows|macos)
|
|
34
42
|
```
|
|
35
43
|
|
|
36
44
|
* Export a production version for each platform.
|
|
37
45
|
```sh
|
|
38
|
-
npm run build
|
|
46
|
+
npm run build:web
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
npx @next2d/builder --platform web --env prd
|
|
39
51
|
```
|
|
40
52
|
|
|
41
53
|
* Starts the test runner.
|
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,29 @@ 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
|
-
"main": "src/index.
|
|
268
|
+
"main": "src/index.ts",
|
|
269
|
+
"type": "module",
|
|
267
270
|
"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 --
|
|
271
|
+
"start": "vite",
|
|
272
|
+
"preview:ios": "npx @next2d/builder --platform ios --preview",
|
|
273
|
+
"preview:android": "npx @next2d/builder --platform android --preview",
|
|
274
|
+
"preview:macos": "npx @next2d/builder --platform macos --preview",
|
|
275
|
+
"preview:windows": "npx @next2d/builder --platform windows --preview",
|
|
276
|
+
"preview:linux": "npx @next2d/builder --platform linux --preview",
|
|
277
|
+
"build:steam:windows": "npx @next2d/builder --platform steam:windows --env prd",
|
|
278
|
+
"build:steam:macos": "npx @next2d/builder --platform steam:macos --env prd",
|
|
279
|
+
"build:steam:linux": "npx @next2d/builder --platform steam:linux --env prd",
|
|
280
|
+
"build:web": "npx @next2d/builder --platform web --env prd",
|
|
273
281
|
"build": "npx @next2d/builder",
|
|
274
|
-
"lint": "eslint src/**/*.
|
|
275
|
-
"test": "npx
|
|
282
|
+
"lint": "eslint src/**/*.ts",
|
|
283
|
+
"test": "npx vitest",
|
|
276
284
|
"generate": "npx @next2d/view-generator"
|
|
277
285
|
}
|
|
278
286
|
}, null, 2) + os.EOL);
|
|
@@ -283,32 +291,46 @@ const createApp = (app_name, template = "@next2d/framework-template") => {
|
|
|
283
291
|
const npmInfo = checkNpmVersion();
|
|
284
292
|
if (!npmInfo.hasMinNpm) {
|
|
285
293
|
if (npmInfo.npmVersion) {
|
|
286
|
-
console.log(
|
|
294
|
+
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
295
|
"Please update to npm 6 or higher for a better, fully supported experience.\n"));
|
|
288
296
|
}
|
|
289
297
|
}
|
|
290
298
|
const ignoreList = [
|
|
291
|
-
"
|
|
292
|
-
"
|
|
293
|
-
"
|
|
294
|
-
".DS_Store",
|
|
295
|
-
".idea",
|
|
296
|
-
"Thumbs.db",
|
|
299
|
+
"# Logs",
|
|
300
|
+
"logs",
|
|
301
|
+
"*.log",
|
|
297
302
|
"npm-debug.log*",
|
|
298
303
|
"yarn-debug.log*",
|
|
299
304
|
"yarn-error.log*",
|
|
305
|
+
"pnpm-debug.log*",
|
|
306
|
+
"lerna-debug.log*",
|
|
307
|
+
"node_modules",
|
|
308
|
+
"dist",
|
|
309
|
+
"dist-ssr",
|
|
310
|
+
"*.local",
|
|
311
|
+
"# Editor directories and files",
|
|
312
|
+
".vscode/*",
|
|
313
|
+
"!.vscode/extensions.json",
|
|
314
|
+
".idea",
|
|
315
|
+
".DS_Store",
|
|
316
|
+
"*.suo",
|
|
317
|
+
"*.ntvs*",
|
|
318
|
+
"*.njsproj",
|
|
319
|
+
"*.sln",
|
|
320
|
+
"*.sw?",
|
|
300
321
|
"src/config/Config.js",
|
|
301
322
|
"src/Packages.js",
|
|
302
323
|
"electron.index.json"
|
|
303
324
|
];
|
|
304
325
|
fs.writeFileSync(path.join(root, ".gitignore"), ignoreList.join(os.EOL));
|
|
305
326
|
install(root, appName, template, [
|
|
327
|
+
"@next2d/player",
|
|
306
328
|
"@next2d/framework",
|
|
307
|
-
"@next2d/
|
|
329
|
+
"@next2d/vite-auto-loader-plugin",
|
|
330
|
+
"jsdom",
|
|
331
|
+
"vite",
|
|
332
|
+
"vitest",
|
|
308
333
|
"electron",
|
|
309
|
-
"webpack",
|
|
310
|
-
"webpack-cli",
|
|
311
|
-
"webpack-dev-server",
|
|
312
334
|
"@capacitor/cli",
|
|
313
335
|
"@capacitor/core",
|
|
314
336
|
"@capacitor/ios",
|
|
@@ -324,28 +346,29 @@ const execute = () => {
|
|
|
324
346
|
const program = new commander.Command(packageJson.name)
|
|
325
347
|
.version(packageJson.version)
|
|
326
348
|
.arguments("<project-directory>")
|
|
327
|
-
.usage(`${
|
|
349
|
+
.usage(`${pc.green("<project-directory>")} [options]`)
|
|
328
350
|
.action((name) => { projectName = name; })
|
|
329
351
|
.option("--info", "print environment debug info")
|
|
330
352
|
.option("--template <path-to-template>", "specify a template for the created project")
|
|
331
353
|
.on("--help", () => {
|
|
332
354
|
console.log();
|
|
333
|
-
console.log(` A custom ${
|
|
334
|
-
console.log(` - a custom template published on npm default: ${
|
|
355
|
+
console.log(` A custom ${pc.cyan("--template")} can be one of:`);
|
|
356
|
+
console.log(` - a custom template published on npm default: ${pc.green("@next2d/framework-template")}`);
|
|
335
357
|
console.log();
|
|
336
358
|
console.log(" If you have any problems, do not hesitate to file an issue:");
|
|
337
|
-
console.log(` ${
|
|
359
|
+
console.log(` ${pc.cyan("https://github.com/Next2D/create-next2d-app/issues/new")}`);
|
|
338
360
|
console.log();
|
|
339
361
|
})
|
|
340
362
|
.parse(process.argv);
|
|
341
363
|
if (typeof projectName === "undefined") {
|
|
342
364
|
console.error("Please specify the project directory:");
|
|
343
|
-
console.log(` npx ${
|
|
365
|
+
console.log(` npx ${pc.cyan(program.name())} ${pc.green("<project-directory>")}`);
|
|
344
366
|
console.log();
|
|
345
367
|
console.log("For example:");
|
|
346
|
-
console.log(` npx ${
|
|
368
|
+
console.log(` npx ${pc.cyan(program.name())} ${pc.green("my-next2d-app")}`);
|
|
347
369
|
process.exit(1);
|
|
348
370
|
}
|
|
349
|
-
|
|
371
|
+
const options = program.opts();
|
|
372
|
+
createApp(projectName, options.template);
|
|
350
373
|
};
|
|
351
374
|
execute();
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-next2d-app",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
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,34 +13,33 @@
|
|
|
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
|
-
"types": "dist",
|
|
18
|
-
"files": [
|
|
19
|
-
"dist"
|
|
20
|
-
],
|
|
21
19
|
"repository": {
|
|
22
20
|
"type": "git",
|
|
23
21
|
"url": "git+https://github.com/Next2D/create-next2d-app.git"
|
|
24
22
|
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
25
26
|
"bin": {
|
|
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
|
}
|