@kurot/cli 1.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/CHANGELOG.md +128 -0
- package/README.md +296 -0
- package/dist/commands/build.d.ts +3 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +59 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/clean.d.ts +3 -0
- package/dist/commands/clean.d.ts.map +1 -0
- package/dist/commands/clean.js +15 -0
- package/dist/commands/clean.js.map +1 -0
- package/dist/commands/create.d.ts +3 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +24 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/dev.d.ts +3 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +25 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/core/config.d.ts +94 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +70 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/dev-server.d.ts +21 -0
- package/dist/core/dev-server.d.ts.map +1 -0
- package/dist/core/dev-server.js +113 -0
- package/dist/core/dev-server.js.map +1 -0
- package/dist/core/errors.d.ts +16 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +23 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/exml/ast.d.ts +243 -0
- package/dist/core/exml/ast.d.ts.map +1 -0
- package/dist/core/exml/ast.js +8 -0
- package/dist/core/exml/ast.js.map +1 -0
- package/dist/core/exml/codegen.d.ts +23 -0
- package/dist/core/exml/codegen.d.ts.map +1 -0
- package/dist/core/exml/codegen.js +422 -0
- package/dist/core/exml/codegen.js.map +1 -0
- package/dist/core/exml/exml-parser.d.ts +27 -0
- package/dist/core/exml/exml-parser.d.ts.map +1 -0
- package/dist/core/exml/exml-parser.js +466 -0
- package/dist/core/exml/exml-parser.js.map +1 -0
- package/dist/core/exml/index.d.ts +52 -0
- package/dist/core/exml/index.d.ts.map +1 -0
- package/dist/core/exml/index.js +51 -0
- package/dist/core/exml/index.js.map +1 -0
- package/dist/core/exml/registry.d.ts +92 -0
- package/dist/core/exml/registry.d.ts.map +1 -0
- package/dist/core/exml/registry.js +177 -0
- package/dist/core/exml/registry.js.map +1 -0
- package/dist/core/exml/xml-parser.d.ts +61 -0
- package/dist/core/exml/xml-parser.d.ts.map +1 -0
- package/dist/core/exml/xml-parser.js +201 -0
- package/dist/core/exml/xml-parser.js.map +1 -0
- package/dist/core/namespace-external-plugin.d.ts +45 -0
- package/dist/core/namespace-external-plugin.d.ts.map +1 -0
- package/dist/core/namespace-external-plugin.js +66 -0
- package/dist/core/namespace-external-plugin.js.map +1 -0
- package/dist/core/pipeline.d.ts +75 -0
- package/dist/core/pipeline.d.ts.map +1 -0
- package/dist/core/pipeline.js +30 -0
- package/dist/core/pipeline.js.map +1 -0
- package/dist/core/plugins/clean-output.d.ts +3 -0
- package/dist/core/plugins/clean-output.d.ts.map +1 -0
- package/dist/core/plugins/clean-output.js +11 -0
- package/dist/core/plugins/clean-output.js.map +1 -0
- package/dist/core/plugins/compile-custom-namespaces.d.ts +19 -0
- package/dist/core/plugins/compile-custom-namespaces.d.ts.map +1 -0
- package/dist/core/plugins/compile-custom-namespaces.js +104 -0
- package/dist/core/plugins/compile-custom-namespaces.js.map +1 -0
- package/dist/core/plugins/compile-engine.d.ts +19 -0
- package/dist/core/plugins/compile-engine.d.ts.map +1 -0
- package/dist/core/plugins/compile-engine.js +75 -0
- package/dist/core/plugins/compile-engine.js.map +1 -0
- package/dist/core/plugins/compile-exml.d.ts +14 -0
- package/dist/core/plugins/compile-exml.d.ts.map +1 -0
- package/dist/core/plugins/compile-exml.js +223 -0
- package/dist/core/plugins/compile-exml.js.map +1 -0
- package/dist/core/plugins/compile-source.d.ts +14 -0
- package/dist/core/plugins/compile-source.d.ts.map +1 -0
- package/dist/core/plugins/compile-source.js +132 -0
- package/dist/core/plugins/compile-source.js.map +1 -0
- package/dist/core/plugins/copy-assets.d.ts +12 -0
- package/dist/core/plugins/copy-assets.d.ts.map +1 -0
- package/dist/core/plugins/copy-assets.js +33 -0
- package/dist/core/plugins/copy-assets.js.map +1 -0
- package/dist/core/plugins/generate-html.d.ts +16 -0
- package/dist/core/plugins/generate-html.d.ts.map +1 -0
- package/dist/core/plugins/generate-html.js +137 -0
- package/dist/core/plugins/generate-html.js.map +1 -0
- package/dist/core/plugins/index.d.ts +21 -0
- package/dist/core/plugins/index.d.ts.map +1 -0
- package/dist/core/plugins/index.js +39 -0
- package/dist/core/plugins/index.js.map +1 -0
- package/dist/core/plugins/manifest.d.ts +14 -0
- package/dist/core/plugins/manifest.d.ts.map +1 -0
- package/dist/core/plugins/manifest.js +28 -0
- package/dist/core/plugins/manifest.js.map +1 -0
- package/dist/core/project.d.ts +95 -0
- package/dist/core/project.d.ts.map +1 -0
- package/dist/core/project.js +79 -0
- package/dist/core/project.js.map +1 -0
- package/dist/core/template.d.ts +13 -0
- package/dist/core/template.d.ts.map +1 -0
- package/dist/core/template.js +79 -0
- package/dist/core/template.js.map +1 -0
- package/dist/define.d.ts +2 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +2 -0
- package/dist/define.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/fs.d.ts +5 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +30 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/logger.d.ts +11 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +18 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +45 -0
- package/templates/empty/kurot.config.ts +13 -0
- package/templates/empty/package.json +17 -0
- package/templates/empty/pnpm-workspace.yaml +3 -0
- package/templates/empty/src/Main.ts +32 -0
- package/templates/empty/template/web/index.html +38 -0
- package/templates/empty/tsconfig.json +10 -0
- package/templates/game/kurot.config.ts +16 -0
- package/templates/game/package.json +19 -0
- package/templates/game/pnpm-workspace.yaml +3 -0
- package/templates/game/resource/assets/eui.json +24 -0
- package/templates/game/resource/assets/eui.png +0 -0
- package/templates/game/resource/default.res.json +15 -0
- package/templates/game/resource/default.thm.json +19 -0
- package/templates/game/resource/skins/ButtonSkin.exml +16 -0
- package/templates/game/resource/skins/CheckBoxSkin.exml +18 -0
- package/templates/game/resource/skins/ComboBoxSkin.exml +31 -0
- package/templates/game/resource/skins/GroupSkin.exml +4 -0
- package/templates/game/resource/skins/HScrollBarSkin.exml +6 -0
- package/templates/game/resource/skins/HSliderSkin.exml +7 -0
- package/templates/game/resource/skins/ImageSkin.exml +4 -0
- package/templates/game/resource/skins/ItemRendererSkin.exml +15 -0
- package/templates/game/resource/skins/LabelSkin.exml +7 -0
- package/templates/game/resource/skins/ListSkin.exml +11 -0
- package/templates/game/resource/skins/PanelSkin.exml +15 -0
- package/templates/game/resource/skins/ProgressBarSkin.exml +11 -0
- package/templates/game/resource/skins/RadioButtonSkin.exml +18 -0
- package/templates/game/resource/skins/ScrollerSkin.exml +8 -0
- package/templates/game/resource/skins/TabBarSkin.exml +6 -0
- package/templates/game/resource/skins/TextInputSkin.exml +22 -0
- package/templates/game/resource/skins/ToggleButtonSkin.exml +21 -0
- package/templates/game/resource/skins/ToggleSwitchSkin.exml +15 -0
- package/templates/game/resource/skins/VScrollBarSkin.exml +6 -0
- package/templates/game/resource/skins/VSliderSkin.exml +7 -0
- package/templates/game/resource/skins/ViewStackSkin.exml +4 -0
- package/templates/game/src/LoadingUI.ts +27 -0
- package/templates/game/src/Main.ts +165 -0
- package/templates/game/template/web/index.html +109 -0
- package/templates/game/template/web/logo.png +0 -0
- package/templates/game/tsconfig.json +10 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { cleanOutput } from './clean-output.js';
|
|
2
|
+
import { compileExml } from './compile-exml.js';
|
|
3
|
+
import { compileEngine } from './compile-engine.js';
|
|
4
|
+
import { compileCustomNamespaces } from './compile-custom-namespaces.js';
|
|
5
|
+
import { compileSource } from './compile-source.js';
|
|
6
|
+
import { generateHtml } from './generate-html.js';
|
|
7
|
+
import { writeManifest } from './manifest.js';
|
|
8
|
+
import { copyAssets } from './copy-assets.js';
|
|
9
|
+
export { cleanOutput } from './clean-output.js';
|
|
10
|
+
export { compileExml } from './compile-exml.js';
|
|
11
|
+
export { compileEngine } from './compile-engine.js';
|
|
12
|
+
export { compileCustomNamespaces } from './compile-custom-namespaces.js';
|
|
13
|
+
export { compileSource } from './compile-source.js';
|
|
14
|
+
export { generateHtml } from './generate-html.js';
|
|
15
|
+
export { writeManifest } from './manifest.js';
|
|
16
|
+
export { copyAssets } from './copy-assets.js';
|
|
17
|
+
/**
|
|
18
|
+
* The standard build sequence.
|
|
19
|
+
*
|
|
20
|
+
* Order matters: `compileCustomNamespaces` must run before `compileSource`,
|
|
21
|
+
* since the latter reads `ctx.outputs.namespaceModules` to mark namespace
|
|
22
|
+
* files external and exclude them from per-file dev output (see
|
|
23
|
+
* `compile-source.ts`). Engine and source compilation report their output
|
|
24
|
+
* paths, then the HTML and manifest referencing them are written, and
|
|
25
|
+
* finally static assets are copied.
|
|
26
|
+
*/
|
|
27
|
+
export function defaultPlugins() {
|
|
28
|
+
return [
|
|
29
|
+
cleanOutput(),
|
|
30
|
+
compileExml(),
|
|
31
|
+
compileEngine(),
|
|
32
|
+
compileCustomNamespaces(),
|
|
33
|
+
compileSource(),
|
|
34
|
+
generateHtml(),
|
|
35
|
+
writeManifest(),
|
|
36
|
+
copyAssets(),
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/plugins/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc;IAC7B,OAAO;QACN,WAAW,EAAE;QACb,WAAW,EAAE;QACb,aAAa,EAAE;QACf,uBAAuB,EAAE;QACzB,aAAa,EAAE;QACf,YAAY,EAAE;QACd,aAAa,EAAE;QACf,UAAU,EAAE;KACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BuildPlugin } from '../pipeline.js';
|
|
2
|
+
/**
|
|
3
|
+
* Writes Egret-style `manifest.json` for release builds:
|
|
4
|
+
*
|
|
5
|
+
* ```json
|
|
6
|
+
* { "initial": ["js/kurot.core.min_<hash>.js", ...], "game": ["js/main.min_<hash>.js"] }
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* `initial` lists the engine chunks (loaded first), `game` the app entry. Skins
|
|
10
|
+
* are embedded in `default.thm.json` and loaded at runtime, so they are not
|
|
11
|
+
* listed here. No-op outside release mode.
|
|
12
|
+
*/
|
|
13
|
+
export declare function writeManifest(): BuildPlugin;
|
|
14
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/core/plugins/manifest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEhE;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,IAAI,WAAW,CAgB3C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { writeFile } from '../../utils/fs.js';
|
|
3
|
+
/**
|
|
4
|
+
* Writes Egret-style `manifest.json` for release builds:
|
|
5
|
+
*
|
|
6
|
+
* ```json
|
|
7
|
+
* { "initial": ["js/kurot.core.min_<hash>.js", ...], "game": ["js/main.min_<hash>.js"] }
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* `initial` lists the engine chunks (loaded first), `game` the app entry. Skins
|
|
11
|
+
* are embedded in `default.thm.json` and loaded at runtime, so they are not
|
|
12
|
+
* listed here. No-op outside release mode.
|
|
13
|
+
*/
|
|
14
|
+
export function writeManifest() {
|
|
15
|
+
return {
|
|
16
|
+
name: 'write manifest.json',
|
|
17
|
+
async apply(ctx) {
|
|
18
|
+
if (ctx.project.mode !== 'release')
|
|
19
|
+
return;
|
|
20
|
+
const manifest = {
|
|
21
|
+
initial: Object.values(ctx.outputs.engine),
|
|
22
|
+
game: [ctx.outputs.skinsScript, ctx.outputs.entryScript].filter(Boolean),
|
|
23
|
+
};
|
|
24
|
+
await writeFile(path.join(ctx.project.outputDir, 'manifest.json'), JSON.stringify(manifest, null, '\t') + '\n');
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../../src/core/plugins/manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa;IAC5B,OAAO;QACN,IAAI,EAAE,qBAAqB;QAC3B,KAAK,CAAC,KAAK,CAAC,GAAiB;YAC5B,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS;gBAAE,OAAO;YAE3C,MAAM,QAAQ,GAAG;gBAChB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC;gBAC1C,IAAI,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;aACxE,CAAC;YACF,MAAM,SAAS,CACd,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,EACjD,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,IAAI,CAC3C,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type ProjectConfig } from './config.js';
|
|
2
|
+
export type BuildMode = 'development' | 'release';
|
|
3
|
+
/**
|
|
4
|
+
* A project-defined EXML namespace (Egret's `xmlns:game="game.*"` convention).
|
|
5
|
+
*
|
|
6
|
+
* `specifier` is the virtual module specifier used in generated `import`
|
|
7
|
+
* statements (e.g. `#ns/game`); it is resolved via an HTML import map to the
|
|
8
|
+
* bundled chunk produced from `entry`, so the app bundle and the skins bundle
|
|
9
|
+
* both import the same module instance.
|
|
10
|
+
*/
|
|
11
|
+
export interface CustomNamespace {
|
|
12
|
+
/**
|
|
13
|
+
* The XML namespace prefix (e.g. `game` for `xmlns:game="game.*"`).
|
|
14
|
+
*/
|
|
15
|
+
readonly prefix: string;
|
|
16
|
+
/**
|
|
17
|
+
* Virtual module specifier used in generated `import` statements.
|
|
18
|
+
*/
|
|
19
|
+
readonly specifier: string;
|
|
20
|
+
/**
|
|
21
|
+
* Absolute path to the barrel file exporting every class in this namespace.
|
|
22
|
+
*/
|
|
23
|
+
readonly entry: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Resolved view of a Kurot project.
|
|
27
|
+
*
|
|
28
|
+
* Loads `kurot.config.ts`, then resolves every project path to an absolute
|
|
29
|
+
* location so plugins never have to touch `process.cwd()` or `path.resolve`
|
|
30
|
+
* themselves. This is the single source of truth for the build pipeline.
|
|
31
|
+
*/
|
|
32
|
+
export interface Project {
|
|
33
|
+
/**
|
|
34
|
+
* Project root (current working directory).
|
|
35
|
+
*/
|
|
36
|
+
readonly root: string;
|
|
37
|
+
/**
|
|
38
|
+
* Build mode this project view was resolved for.
|
|
39
|
+
*/
|
|
40
|
+
readonly mode: BuildMode;
|
|
41
|
+
/**
|
|
42
|
+
* Validated user configuration.
|
|
43
|
+
*/
|
|
44
|
+
readonly config: ProjectConfig;
|
|
45
|
+
/**
|
|
46
|
+
* Absolute path to the entry source file.
|
|
47
|
+
*/
|
|
48
|
+
readonly entry: string;
|
|
49
|
+
/**
|
|
50
|
+
* Absolute path to the source root directory (`src/`).
|
|
51
|
+
*/
|
|
52
|
+
readonly srcDir: string;
|
|
53
|
+
/**
|
|
54
|
+
* Absolute output directory.
|
|
55
|
+
* - development: `bin-debug`
|
|
56
|
+
* - release: `bin-release/web/<timestamp>` (Egret-style versioned folder)
|
|
57
|
+
*/
|
|
58
|
+
readonly outputDir: string;
|
|
59
|
+
/**
|
|
60
|
+
* Absolute path to the `resource/` directory.
|
|
61
|
+
*/
|
|
62
|
+
readonly resourceDir: string;
|
|
63
|
+
/**
|
|
64
|
+
* Absolute path to the project-owned HTML template, when configured.
|
|
65
|
+
*/
|
|
66
|
+
readonly htmlTemplate?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Absolute path to the theme file, when EXML is enabled.
|
|
69
|
+
*/
|
|
70
|
+
readonly themeFile?: string;
|
|
71
|
+
/**
|
|
72
|
+
* `@kurot/*` engine packages this project depends on (excluding the CLI).
|
|
73
|
+
* Each is bundled into its own chunk and wired up via an HTML import map.
|
|
74
|
+
*/
|
|
75
|
+
readonly enginePackages: string[];
|
|
76
|
+
/**
|
|
77
|
+
* Project-defined EXML namespaces, resolved from `config.exml.namespaces`.
|
|
78
|
+
*/
|
|
79
|
+
readonly customNamespaces: CustomNamespace[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Base output folder names, used by both build and clean.
|
|
83
|
+
*/
|
|
84
|
+
export declare const OUTPUT_DIRS: {
|
|
85
|
+
readonly development: "bin-debug";
|
|
86
|
+
readonly release: "bin-release";
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Loads and resolves the project rooted at the current working directory.
|
|
90
|
+
*
|
|
91
|
+
* @param mode - The build mode to resolve the project for
|
|
92
|
+
* @returns The resolved project view
|
|
93
|
+
*/
|
|
94
|
+
export declare function loadProject(mode: BuildMode): Promise<Project>;
|
|
95
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/core/project.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,SAAS,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC/B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,OAAO;IACvB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IAClC;;OAEG;IACH,QAAQ,CAAC,gBAAgB,EAAE,eAAe,EAAE,CAAC;CAC7C;AAED;;GAEG;AACH,eAAO,MAAM,WAAW;;;CAAgE,CAAC;AAEzF;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAqBnE"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import { loadConfig } from './config.js';
|
|
4
|
+
/**
|
|
5
|
+
* Base output folder names, used by both build and clean.
|
|
6
|
+
*/
|
|
7
|
+
export const OUTPUT_DIRS = { development: 'bin-debug', release: 'bin-release' };
|
|
8
|
+
/**
|
|
9
|
+
* Loads and resolves the project rooted at the current working directory.
|
|
10
|
+
*
|
|
11
|
+
* @param mode - The build mode to resolve the project for
|
|
12
|
+
* @returns The resolved project view
|
|
13
|
+
*/
|
|
14
|
+
export async function loadProject(mode) {
|
|
15
|
+
const root = process.cwd();
|
|
16
|
+
const config = await loadConfig();
|
|
17
|
+
const outputDir = mode === 'release'
|
|
18
|
+
? path.resolve(root, OUTPUT_DIRS.release, 'web', timestamp())
|
|
19
|
+
: path.resolve(root, config.output.dir);
|
|
20
|
+
return {
|
|
21
|
+
root,
|
|
22
|
+
mode,
|
|
23
|
+
config,
|
|
24
|
+
entry: path.resolve(root, config.entry),
|
|
25
|
+
srcDir: path.resolve(root, 'src'),
|
|
26
|
+
outputDir,
|
|
27
|
+
resourceDir: path.resolve(root, 'resource'),
|
|
28
|
+
htmlTemplate: config.html ? path.resolve(root, config.html.template) : undefined,
|
|
29
|
+
themeFile: config.exml ? path.resolve(root, config.exml.themeFile) : undefined,
|
|
30
|
+
enginePackages: detectEnginePackages(root),
|
|
31
|
+
customNamespaces: resolveCustomNamespaces(root, config.exml?.namespaces),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The specifier prefix used for project-defined EXML namespaces (kept out of
|
|
36
|
+
* npm's `@scope` space).
|
|
37
|
+
*/
|
|
38
|
+
const NAMESPACE_SPECIFIER_PREFIX = '#ns/';
|
|
39
|
+
/**
|
|
40
|
+
* Resolves `config.exml.namespaces` into `CustomNamespace` entries with
|
|
41
|
+
* absolute barrel paths.
|
|
42
|
+
*/
|
|
43
|
+
function resolveCustomNamespaces(root, namespaces) {
|
|
44
|
+
if (!namespaces)
|
|
45
|
+
return [];
|
|
46
|
+
return Object.entries(namespaces).map(([prefix, entry]) => ({
|
|
47
|
+
prefix,
|
|
48
|
+
specifier: `${NAMESPACE_SPECIFIER_PREFIX}${prefix}`,
|
|
49
|
+
entry: path.resolve(root, entry),
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Reads `@kurot/*` runtime dependencies (excluding the CLI) from package.json.
|
|
54
|
+
*/
|
|
55
|
+
function detectEnginePackages(root) {
|
|
56
|
+
try {
|
|
57
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf-8'));
|
|
58
|
+
return Object.keys(pkg.dependencies ?? {})
|
|
59
|
+
.filter(name => name.startsWith('@kurot/') && name !== '@kurot/cli')
|
|
60
|
+
.sort();
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Egret-style `YYMMDDHHmmss` version stamp.
|
|
68
|
+
*/
|
|
69
|
+
function timestamp() {
|
|
70
|
+
const d = new Date();
|
|
71
|
+
const p = (n) => String(n).padStart(2, '0');
|
|
72
|
+
return (String(d.getFullYear() % 100) +
|
|
73
|
+
p(d.getMonth() + 1) +
|
|
74
|
+
p(d.getDate()) +
|
|
75
|
+
p(d.getHours()) +
|
|
76
|
+
p(d.getMinutes()) +
|
|
77
|
+
p(d.getSeconds()));
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/core/project.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAsB,MAAM,aAAa,CAAC;AAoF7D;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAW,CAAC;AAEzF;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,IAAe;IAChD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC3B,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;IAClC,MAAM,SAAS,GACd,IAAI,KAAK,SAA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+
export declare const TEMPLATES: readonly ["game", "empty"];
|
|
2
|
+
export type TemplateName = (typeof TEMPLATES)[number];
|
|
3
|
+
/**
|
|
4
|
+
* Scaffolds a new project by copying `templates/<template>/` into `./<name>/`,
|
|
5
|
+
* then writing a fresh `package.json`:
|
|
6
|
+
*
|
|
7
|
+
* - `name` is set to the project name.
|
|
8
|
+
* - `@kurot/cli` is pinned to the version of the CLI doing the scaffolding,
|
|
9
|
+
* so a project always uses the CLI that created it (never a stale template pin).
|
|
10
|
+
* - `@kurot/*` engine packages are set to `latest`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function scaffoldProject(name: string, template: TemplateName): Promise<void>;
|
|
13
|
+
//# sourceMappingURL=template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/core/template.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,SAAS,4BAA6B,CAAC;AACpD,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAEtD;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBzF"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import * as fs from 'node:fs/promises';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { copyDir, writeFile, exists } from '../utils/fs.js';
|
|
5
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
const TEMPLATES_DIR = path.resolve(__dirname, '../../templates');
|
|
7
|
+
const CLI_PKG = path.resolve(__dirname, '../../package.json');
|
|
8
|
+
export const TEMPLATES = ['game', 'empty'];
|
|
9
|
+
/**
|
|
10
|
+
* Scaffolds a new project by copying `templates/<template>/` into `./<name>/`,
|
|
11
|
+
* then writing a fresh `package.json`:
|
|
12
|
+
*
|
|
13
|
+
* - `name` is set to the project name.
|
|
14
|
+
* - `@kurot/cli` is pinned to the version of the CLI doing the scaffolding,
|
|
15
|
+
* so a project always uses the CLI that created it (never a stale template pin).
|
|
16
|
+
* - `@kurot/*` engine packages are set to `latest`.
|
|
17
|
+
*/
|
|
18
|
+
export async function scaffoldProject(name, template) {
|
|
19
|
+
const templateDir = path.join(TEMPLATES_DIR, template);
|
|
20
|
+
const destDir = path.resolve(name);
|
|
21
|
+
if (!(await exists(templateDir))) {
|
|
22
|
+
throw new Error(`Template "${template}" not found at ${templateDir}`);
|
|
23
|
+
}
|
|
24
|
+
if (await exists(destDir)) {
|
|
25
|
+
throw new Error(`Directory "${name}" already exists`);
|
|
26
|
+
}
|
|
27
|
+
await copyDir(templateDir, destDir);
|
|
28
|
+
const pkgPath = path.join(destDir, 'package.json');
|
|
29
|
+
if (await exists(pkgPath)) {
|
|
30
|
+
const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf-8'));
|
|
31
|
+
pkg.name = path.basename(destDir);
|
|
32
|
+
const cliVersion = await readCliVersion();
|
|
33
|
+
await pinKurotDeps(pkg.dependencies, cliVersion);
|
|
34
|
+
await pinKurotDeps(pkg.devDependencies, cliVersion);
|
|
35
|
+
await writeFile(pkgPath, JSON.stringify(pkg, null, '\t') + '\n');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Rewrites `@kurot/*` ranges: the CLI to its own version, and each engine
|
|
40
|
+
* package to the concrete latest version (`^x.y.z`) resolved from the registry.
|
|
41
|
+
*/
|
|
42
|
+
async function pinKurotDeps(deps, cliVersion) {
|
|
43
|
+
if (!deps)
|
|
44
|
+
return;
|
|
45
|
+
await Promise.all(Object.keys(deps).map(async (dep) => {
|
|
46
|
+
if (dep === '@kurot/cli')
|
|
47
|
+
deps[dep] = `^${cliVersion}`;
|
|
48
|
+
else if (dep.startsWith('@kurot/'))
|
|
49
|
+
deps[dep] = await resolveLatest(dep);
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Resolves a package's latest published version to a caret range (`^x.y.z`).
|
|
54
|
+
* Falls back to the `latest` dist-tag when the registry is unreachable or the
|
|
55
|
+
* package is unpublished, deferring resolution to install time.
|
|
56
|
+
*/
|
|
57
|
+
async function resolveLatest(pkg) {
|
|
58
|
+
try {
|
|
59
|
+
const url = `https://registry.npmjs.org/${pkg.replace('/', '%2F')}/latest`;
|
|
60
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(3000) });
|
|
61
|
+
if (res.ok) {
|
|
62
|
+
const data = (await res.json());
|
|
63
|
+
if (data.version)
|
|
64
|
+
return `^${data.version}`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// Offline / unpublished — fall back below.
|
|
69
|
+
}
|
|
70
|
+
return 'latest';
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Reads this CLI's own version from its package.json.
|
|
74
|
+
*/
|
|
75
|
+
async function readCliVersion() {
|
|
76
|
+
const pkg = JSON.parse(await fs.readFile(CLI_PKG, 'utf-8'));
|
|
77
|
+
return pkg.version;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/core/template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE5D,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,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,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,cAAc;IAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAwB,CAAC;IACnF,OAAO,GAAG,CAAC,OAAO,CAAC;AACpB,CAAC"}
|
package/dist/define.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/define.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
|
+
import { Command } from 'commander';
|
|
6
|
+
import { buildCommand } from './commands/build.js';
|
|
7
|
+
import { createCommand } from './commands/create.js';
|
|
8
|
+
import { cleanCommand } from './commands/clean.js';
|
|
9
|
+
import { devCommand } from './commands/dev.js';
|
|
10
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf-8'));
|
|
12
|
+
const program = new Command();
|
|
13
|
+
program.name('kurot').description('Kurot - Egret Next CLI').version(pkg.version);
|
|
14
|
+
program.addCommand(buildCommand);
|
|
15
|
+
program.addCommand(devCommand);
|
|
16
|
+
program.addCommand(createCommand);
|
|
17
|
+
program.addCommand(cleanCommand);
|
|
18
|
+
program.parse();
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AAElF,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,wBAAwB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAEjF,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AACjC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AAC/B,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAClC,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AAEjC,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function ensureDir(dir: string): Promise<void>;
|
|
2
|
+
export declare function copyDir(src: string, dest: string, filter?: (name: string) => boolean): Promise<void>;
|
|
3
|
+
export declare function writeFile(filePath: string, content: string): Promise<void>;
|
|
4
|
+
export declare function exists(filePath: string): Promise<boolean>;
|
|
5
|
+
//# sourceMappingURL=fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"AAGA,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1D;AAED,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAY1G;AAED,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGhF;AAED,wBAAsB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAK/D"}
|
package/dist/utils/fs.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as fs from 'node:fs/promises';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
export async function ensureDir(dir) {
|
|
4
|
+
await fs.mkdir(dir, { recursive: true });
|
|
5
|
+
}
|
|
6
|
+
export async function copyDir(src, dest, filter) {
|
|
7
|
+
await ensureDir(dest);
|
|
8
|
+
const entries = await fs.readdir(src, { withFileTypes: true });
|
|
9
|
+
for (const entry of entries) {
|
|
10
|
+
const srcPath = path.join(src, entry.name);
|
|
11
|
+
const destPath = path.join(dest, entry.name);
|
|
12
|
+
if (entry.isDirectory()) {
|
|
13
|
+
await copyDir(srcPath, destPath, filter);
|
|
14
|
+
}
|
|
15
|
+
else if (!filter || filter(entry.name)) {
|
|
16
|
+
await fs.copyFile(srcPath, destPath);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export async function writeFile(filePath, content) {
|
|
21
|
+
await ensureDir(path.dirname(filePath));
|
|
22
|
+
await fs.writeFile(filePath, content, 'utf-8');
|
|
23
|
+
}
|
|
24
|
+
export async function exists(filePath) {
|
|
25
|
+
return fs
|
|
26
|
+
.access(filePath)
|
|
27
|
+
.then(() => true)
|
|
28
|
+
.catch(() => false);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=fs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/utils/fs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAW;IAC1C,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,GAAW,EAAE,IAAY,EAAE,MAAkC;IAC1F,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;IACtB,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACzB,MAAM,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC1C,CAAC;aAAM,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1C,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACtC,CAAC;IACF,CAAC;AACF,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAgB,EAAE,OAAe;IAChE,MAAM,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxC,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,QAAgB;IAC5C,OAAO,EAAE;SACP,MAAM,CAAC,QAAQ,CAAC;SAChB,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;SAChB,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const logger: {
|
|
2
|
+
info: (msg: string) => void;
|
|
3
|
+
success: (msg: string) => void;
|
|
4
|
+
warn: (msg: string) => void;
|
|
5
|
+
error: (msg: string) => void;
|
|
6
|
+
/**
|
|
7
|
+
* Logs a single pipeline step, indented under the current command.
|
|
8
|
+
*/
|
|
9
|
+
step: (msg: string) => void;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,MAAM;gBACN,MAAM,KAAG,IAAI;mBACV,MAAM,KAAG,IAAI;gBAChB,MAAM,KAAG,IAAI;iBACZ,MAAM,KAAG,IAAI;IAC1B;;OAEG;gBACS,MAAM,KAAG,IAAI;CACzB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const reset = '\x1b[0m';
|
|
2
|
+
const green = '\x1b[32m';
|
|
3
|
+
const yellow = '\x1b[33m';
|
|
4
|
+
const red = '\x1b[31m';
|
|
5
|
+
const cyan = '\x1b[36m';
|
|
6
|
+
const dim = '\x1b[2m';
|
|
7
|
+
const tag = `${cyan}[kurot]${reset}`;
|
|
8
|
+
export const logger = {
|
|
9
|
+
info: (msg) => console.log(`${tag} ${msg}`),
|
|
10
|
+
success: (msg) => console.log(`${tag} ${green}${msg}${reset}`),
|
|
11
|
+
warn: (msg) => console.warn(`${tag} ${yellow}${msg}${reset}`),
|
|
12
|
+
error: (msg) => console.error(`${tag} ${red}${msg}${reset}`),
|
|
13
|
+
/**
|
|
14
|
+
* Logs a single pipeline step, indented under the current command.
|
|
15
|
+
*/
|
|
16
|
+
step: (msg) => console.log(`${tag} ${dim}›${reset} ${msg}`),
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,KAAK,GAAG,UAAU,CAAC;AACzB,MAAM,MAAM,GAAG,UAAU,CAAC;AAC1B,MAAM,GAAG,GAAG,UAAU,CAAC;AACvB,MAAM,IAAI,GAAG,UAAU,CAAC;AACxB,MAAM,GAAG,GAAG,SAAS,CAAC;AAEtB,MAAM,GAAG,GAAG,GAAG,IAAI,UAAU,KAAK,EAAE,CAAC;AAErC,MAAM,CAAC,MAAM,MAAM,GAAG;IACrB,IAAI,EAAE,CAAC,GAAW,EAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;IACzD,OAAO,EAAE,CAAC,GAAW,EAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,KAAK,GAAG,GAAG,GAAG,KAAK,EAAE,CAAC;IAC5E,IAAI,EAAE,CAAC,GAAW,EAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,IAAI,MAAM,GAAG,GAAG,GAAG,KAAK,EAAE,CAAC;IAC3E,KAAK,EAAE,CAAC,GAAW,EAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,KAAK,EAAE,CAAC;IAC1E;;OAEG;IACH,IAAI,EAAE,CAAC,GAAW,EAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,GAAG,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;CACzE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kurot/cli",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "Kurot CLI - build tool for the Kurot game engine",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"kurot": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/define.js",
|
|
10
|
+
"types": "./dist/define.d.ts",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"templates",
|
|
14
|
+
"README.md",
|
|
15
|
+
"CHANGELOG.md"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc --build",
|
|
22
|
+
"dev": "tsc --watch",
|
|
23
|
+
"clean": "rm -rf dist",
|
|
24
|
+
"test": "vitest run",
|
|
25
|
+
"test:watch": "vitest",
|
|
26
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
27
|
+
"kurot": "tsx src/index.ts"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"commander": "^13.0.0",
|
|
31
|
+
"esbuild": "^0.25.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^22.0.0",
|
|
35
|
+
"tsx": "^4.21.0",
|
|
36
|
+
"typescript": "^5.6.0",
|
|
37
|
+
"vitest": "^4.1.4"
|
|
38
|
+
},
|
|
39
|
+
"packageManager": "pnpm@10.33.0",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "git+https://github.com/kurot-engine/kurot.git",
|
|
43
|
+
"directory": "packages/cli"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
target: 'html5',
|
|
3
|
+
entry: 'src/Main.ts',
|
|
4
|
+
output: { dir: 'bin-debug' },
|
|
5
|
+
html: { template: 'template/web/index.html' },
|
|
6
|
+
stage: {
|
|
7
|
+
width: 640,
|
|
8
|
+
height: 1136,
|
|
9
|
+
scaleMode: 'showAll',
|
|
10
|
+
orientation: 'auto',
|
|
11
|
+
frameRate: 60,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "kurot-empty",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "kurot build",
|
|
7
|
+
"release": "kurot build --release",
|
|
8
|
+
"dev": "kurot dev",
|
|
9
|
+
"clean": "kurot clean"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@kurot/core": "latest"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@kurot/cli": "latest"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kurot 空白项目模板
|
|
3
|
+
*
|
|
4
|
+
* 最小化入口,只依赖 @kurot/core,不含 UI 组件。
|
|
5
|
+
* 适用于纯 Canvas 渲染、自定义绘制、动画实验等场景。
|
|
6
|
+
*
|
|
7
|
+
* 生命周期:constructor → ADDED_TO_STAGE → $onAddToStage
|
|
8
|
+
*/
|
|
9
|
+
import { createPlayer, Sprite, Event } from '@kurot/core';
|
|
10
|
+
|
|
11
|
+
class Main extends Sprite {
|
|
12
|
+
public constructor() {
|
|
13
|
+
super();
|
|
14
|
+
this.addEventListener(Event.ADDED_TO_STAGE, this.onAddedToStage);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
private onAddedToStage(_event: Event): void {
|
|
18
|
+
// 在这里编写你的游戏逻辑
|
|
19
|
+
console.log('Kurot game started');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// ── 启动 ──────────────────────────────────────────────────────────────────
|
|
24
|
+
const app = createPlayer({
|
|
25
|
+
canvas: document.getElementById('gameCanvas') as HTMLCanvasElement,
|
|
26
|
+
contentWidth: 640,
|
|
27
|
+
contentHeight: 1136,
|
|
28
|
+
scaleMode: 'showAll',
|
|
29
|
+
frameRate: 60,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
app.start(new Main());
|