@nanoforge-dev/schematics 1.2.2 → 2.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/dist/collection.json +10 -0
- package/dist/index.cjs +2 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -26
- package/dist/index.d.ts +1 -26
- package/dist/index.js +1 -30
- package/dist/index.js.map +1 -1
- package/dist/libs/application/application.factory.d.ts +5 -0
- package/dist/libs/application/application.factory.js +6 -2
- package/dist/libs/application/application.factory.js.map +1 -1
- package/dist/libs/application/files/js/package.json.template +2 -1
- package/dist/libs/application/files/ts/package.json.template +2 -1
- package/dist/libs/application/schema.json +6 -5
- package/dist/libs/component/component.factory.d.ts +27 -0
- package/dist/libs/component/component.factory.js +50 -0
- package/dist/libs/component/component.factory.js.map +1 -0
- package/dist/libs/component/files/js/__fileName__.component.js +78 -0
- package/dist/libs/component/files/ts/__fileName__.component.ts +61 -0
- package/dist/libs/component/schema.json +30 -0
- package/dist/libs/configuration/configuration.factory.d.ts +8 -3
- package/dist/libs/configuration/configuration.factory.js +32 -49
- package/dist/libs/configuration/configuration.factory.js.map +1 -1
- package/dist/libs/configuration/schema.json +9 -8
- package/dist/libs/docker/docker.factory.d.ts +2 -7
- package/dist/libs/docker/docker.factory.js +2 -24
- package/dist/libs/docker/docker.factory.js.map +1 -1
- package/dist/libs/docker/files/.dockerignore +1 -1
- package/dist/libs/docker/files/Dockerfile +10 -24
- package/dist/libs/docker/schema.json +4 -13
- package/dist/libs/part-base/files/js/__nanoforgeFolder__/client.save.json +1 -1
- package/dist/libs/part-base/files/js/__nanoforgeFolder__/server.save.json +1 -1
- package/dist/libs/part-base/files/js/__part__/components/example.component.js +29 -23
- package/dist/libs/part-base/files/js/__part__/systems/example.system.js +1 -1
- package/dist/libs/part-base/files/ts/__nanoforgeFolder__/client.save.json +1 -1
- package/dist/libs/part-base/files/ts/__nanoforgeFolder__/server.save.json +1 -1
- package/dist/libs/part-base/files/ts/__part__/components/example.component.ts +29 -23
- package/dist/libs/part-base/part-base.factory.d.ts +5 -10
- package/dist/libs/part-base/part-base.factory.js +6 -34
- package/dist/libs/part-base/part-base.factory.js.map +1 -1
- package/dist/libs/part-base/schema.json +4 -12
- package/dist/libs/part-main/part-main.factory.d.ts +14 -9
- package/dist/libs/part-main/part-main.factory.js +106 -63
- package/dist/libs/part-main/part-main.factory.js.map +1 -1
- package/dist/libs/part-main/schema.json +13 -12
- package/dist/libs/system/files/js/__fileName__.system.js +44 -0
- package/dist/libs/system/files/ts/__fileName__.system.ts +31 -0
- package/dist/libs/system/schema.json +30 -0
- package/dist/libs/system/system.factory.d.ts +27 -0
- package/dist/libs/system/system.factory.js +53 -0
- package/dist/libs/system/system.factory.js.map +1 -0
- package/package.json +1 -1
|
@@ -33,31 +33,6 @@ var deepMerge = /* @__PURE__ */ __name((target, ...sources) => {
|
|
|
33
33
|
return deepMerge(target, ...sources);
|
|
34
34
|
}, "deepMerge");
|
|
35
35
|
|
|
36
|
-
// src/defaults.ts
|
|
37
|
-
var DEFAULT_CONFIG = {
|
|
38
|
-
client: {
|
|
39
|
-
build: {
|
|
40
|
-
entryFile: "client/main.ts",
|
|
41
|
-
outDir: ".nanoforge/client"
|
|
42
|
-
},
|
|
43
|
-
runtime: {
|
|
44
|
-
dir: ".nanoforge/client"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var DEFAULT_SERVER_CONFIG = {
|
|
49
|
-
server: {
|
|
50
|
-
enable: true,
|
|
51
|
-
build: {
|
|
52
|
-
entryFile: "server/main.ts",
|
|
53
|
-
outDir: ".nanoforge/server"
|
|
54
|
-
},
|
|
55
|
-
runtime: {
|
|
56
|
-
dir: ".nanoforge/server"
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
36
|
// src/utils/config/config.declarator.ts
|
|
62
37
|
var ConfigDeclarator = class {
|
|
63
38
|
static {
|
|
@@ -65,17 +40,7 @@ var ConfigDeclarator = class {
|
|
|
65
40
|
}
|
|
66
41
|
declare(baseContent, options) {
|
|
67
42
|
const content = JSON.parse(baseContent);
|
|
68
|
-
|
|
69
|
-
return JSON.stringify(
|
|
70
|
-
deepMerge(
|
|
71
|
-
DEFAULT_CONFIG,
|
|
72
|
-
hasServer ? DEFAULT_SERVER_CONFIG : void 0,
|
|
73
|
-
baseContent,
|
|
74
|
-
options
|
|
75
|
-
),
|
|
76
|
-
null,
|
|
77
|
-
2
|
|
78
|
-
);
|
|
43
|
+
return JSON.stringify(deepMerge(content, options), null, 2);
|
|
79
44
|
}
|
|
80
45
|
};
|
|
81
46
|
|
|
@@ -111,17 +76,8 @@ var ConfigFinder = class {
|
|
|
111
76
|
|
|
112
77
|
// src/libs/configuration/configuration.factory.ts
|
|
113
78
|
var transform = /* @__PURE__ */ __name((schema) => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
enable: schema.server ?? false
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
if (schema.language === "js") {
|
|
120
|
-
res["client"] = { build: { entryFile: "client/main.js" } };
|
|
121
|
-
if (schema.server && "server" in res && res.server)
|
|
122
|
-
res.server["build"] = { entryFile: "server/main.js" };
|
|
123
|
-
}
|
|
124
|
-
return res;
|
|
79
|
+
void schema;
|
|
80
|
+
return {};
|
|
125
81
|
}, "transform");
|
|
126
82
|
var generate = /* @__PURE__ */ __name((options, path) => {
|
|
127
83
|
return apply(url(join2("./files")), [
|
|
@@ -143,11 +99,38 @@ var addConfiguration = /* @__PURE__ */ __name((options, path) => {
|
|
|
143
99
|
return tree;
|
|
144
100
|
};
|
|
145
101
|
}, "addConfiguration");
|
|
102
|
+
var getConfig = /* @__PURE__ */ __name((schema) => {
|
|
103
|
+
const res = {
|
|
104
|
+
name: schema.name,
|
|
105
|
+
language: schema.language,
|
|
106
|
+
initFunctions: schema.initFunctions,
|
|
107
|
+
client: {
|
|
108
|
+
enable: true
|
|
109
|
+
},
|
|
110
|
+
server: {
|
|
111
|
+
enable: schema.server ?? false
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
if (schema.language === "js") {
|
|
115
|
+
if ("client" in res && res.client) {
|
|
116
|
+
res.client["build"] = { entry: "client/main.js" };
|
|
117
|
+
res.client["editor"] = { entry: ".nanoforge/editor/client/main.js" };
|
|
118
|
+
}
|
|
119
|
+
if (schema.server && "server" in res && res.server) {
|
|
120
|
+
res.server["build"] = { entry: "server/main.js" };
|
|
121
|
+
res.server["editor"] = { entry: ".nanoforge/editor/client/main.js" };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return res;
|
|
125
|
+
}, "getConfig");
|
|
146
126
|
var main = /* @__PURE__ */ __name((schema) => {
|
|
147
127
|
const options = transform(schema);
|
|
148
|
-
const directory = schema.directory
|
|
128
|
+
const directory = schema.directory;
|
|
149
129
|
return branchAndMerge(
|
|
150
|
-
chain([
|
|
130
|
+
chain([
|
|
131
|
+
mergeWith(generate(options, directory)),
|
|
132
|
+
addConfiguration(getConfig(schema), directory)
|
|
133
|
+
])
|
|
151
134
|
);
|
|
152
135
|
}, "main");
|
|
153
136
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/libs/configuration/configuration.factory.ts","../../../src/utils/object.ts","../../../src/
|
|
1
|
+
{"version":3,"sources":["../../../src/libs/configuration/configuration.factory.ts","../../../src/utils/object.ts","../../../src/utils/config/config.declarator.ts","../../../src/utils/config/config.finder.ts"],"sourcesContent":["import { type Path, join, normalize, strings } from \"@angular-devkit/core\";\nimport {\n type Rule,\n type Source,\n type Tree,\n apply,\n branchAndMerge,\n chain,\n mergeWith,\n move,\n template,\n url,\n} from \"@angular-devkit/schematics\";\n\nimport { ConfigDeclarator } from \"@utils/config/config.declarator\";\nimport { ConfigFinder } from \"@utils/config/config.finder\";\nimport { type Config } from \"@utils/config/config.type\";\nimport { type DeepPartial } from \"@utils/types\";\n\nimport { type ConfigurationOptions } from \"./configuration.options\";\nimport { type ConfigurationSchema } from \"./configuration.schema\";\n\nconst transform = (schema: ConfigurationSchema): ConfigurationOptions => {\n void schema;\n\n return {};\n};\n\nconst generate = (options: ConfigurationOptions, path: string): Source => {\n return apply(url(join(\"./files\" as Path)), [\n template({\n ...strings,\n ...options,\n }),\n move(normalize(path)),\n ]);\n};\n\nconst addConfiguration = (options: DeepPartial<Config>, path: Path) => {\n return (tree: Tree) => {\n const config = new ConfigFinder(tree).find(path);\n if (!config) return tree;\n\n const content = tree.read(config)?.toString();\n const declarator = new ConfigDeclarator();\n\n if (!content) return tree;\n\n tree.overwrite(config, declarator.declare(content, options));\n return tree;\n };\n};\n\nconst getConfig = (schema: ConfigurationSchema): DeepPartial<Config> => {\n const res: DeepPartial<Config> = {\n name: schema.name,\n language: schema.language,\n initFunctions: schema.initFunctions,\n client: {\n enable: true,\n },\n server: {\n enable: schema.server ?? false,\n },\n };\n\n if (schema.language === \"js\") {\n if (\"client\" in res && res.client) {\n res.client[\"build\"] = { entry: \"client/main.js\" };\n res.client[\"editor\"] = { entry: \".nanoforge/editor/client/main.js\" };\n }\n if (schema.server && \"server\" in res && res.server) {\n res.server[\"build\"] = { entry: \"server/main.js\" };\n res.server[\"editor\"] = { entry: \".nanoforge/editor/client/main.js\" };\n }\n }\n\n return res;\n};\n\nexport const main = (schema: ConfigurationSchema): Rule => {\n const options = transform(schema);\n const directory = schema.directory;\n\n return branchAndMerge(\n chain([\n mergeWith(generate(options, directory)),\n addConfiguration(getConfig(schema), directory as Path),\n ]),\n );\n};\n","export const isObject = (item: any) => {\n return item && typeof item === \"object\" && !Array.isArray(item);\n};\n\nexport const deepMerge = (target: any, ...sources: [any, ...any[]]): any => {\n if (!sources.length) return target;\n const source = sources.shift();\n\n if (isObject(target) && isObject(source)) {\n for (const key in source) {\n if (isObject(source[key])) {\n if (!target[key]) Object.assign(target, { [key]: {} });\n deepMerge(target[key], source[key]);\n } else {\n Object.assign(target, { [key]: source[key] });\n }\n }\n }\n\n return deepMerge(target, ...sources);\n};\n","import { type Config } from \"@utils/config/config.type\";\nimport { deepMerge } from \"@utils/object\";\nimport { type DeepPartial } from \"@utils/types\";\n\nexport class ConfigDeclarator {\n public declare(baseContent: string, options: DeepPartial<Config>): string {\n const content = JSON.parse(baseContent);\n return JSON.stringify(deepMerge(content, options), null, 2);\n }\n}\n","import { type Path, join } from \"@angular-devkit/core\";\nimport { type DirEntry, type Tree } from \"@angular-devkit/schematics\";\n\nexport interface FindOptions {\n path: Path;\n}\n\nexport class ConfigFinder {\n constructor(private tree: Tree) {}\n\n public find(path: Path): Path | null {\n const dir = this.tree.getDir(path);\n return this.findIn(dir);\n }\n\n /**\n * Recursively searches for the module file in the given directory.\n *\n * @param directory - The directory to search in.\n * @returns The path to the module file, or null if not found.\n */\n private findIn(directory: DirEntry | null): Path | null {\n if (!directory) {\n return null;\n }\n const moduleFilename = directory.subfiles.find((filename) =>\n /^nanoforge.config.json$/.test(filename),\n );\n return moduleFilename !== undefined\n ? join(directory.path, moduleFilename.valueOf())\n : this.findIn(directory.parent);\n }\n}\n"],"mappings":";;;;AAAA,SAAoB,QAAAA,OAAM,WAAW,eAAe;AACpD;AAAA,EAIE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACZA,IAAM,WAAW,wBAAC,SAAc;AACrC,SAAO,QAAQ,OAAO,SAAS,YAAY,CAAC,MAAM,QAAQ,IAAI;AAChE,GAFwB;AAIjB,IAAM,YAAY,wBAAC,WAAgB,YAAkC;AAC1E,MAAI,CAAC,QAAQ,OAAQ,QAAO;AAC5B,QAAM,SAAS,QAAQ,MAAM;AAE7B,MAAI,SAAS,MAAM,KAAK,SAAS,MAAM,GAAG;AACxC,eAAW,OAAO,QAAQ;AACxB,UAAI,SAAS,OAAO,GAAG,CAAC,GAAG;AACzB,YAAI,CAAC,OAAO,GAAG,EAAG,QAAO,OAAO,QAAQ,EAAE,CAAC,GAAG,GAAG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,UAAU,MAAM,GAAG,SAAiB;AAAA,IACvD,CAAC;AAAA,EACH;AACF,GAVoB;","names":["join","join"]}
|
|
@@ -7,15 +7,12 @@
|
|
|
7
7
|
"name": {
|
|
8
8
|
"type": "string",
|
|
9
9
|
"description": "The name of the application",
|
|
10
|
-
"
|
|
11
|
-
"$source": "argv",
|
|
12
|
-
"index": 0
|
|
13
|
-
},
|
|
14
|
-
"x-prompt": "What name would you like to use for the new project ?"
|
|
10
|
+
"default": "nanoforge-app"
|
|
15
11
|
},
|
|
16
12
|
"directory": {
|
|
17
13
|
"type": "string",
|
|
18
|
-
"description": "NanoForge application destination directory"
|
|
14
|
+
"description": "NanoForge application destination directory",
|
|
15
|
+
"default": "."
|
|
19
16
|
},
|
|
20
17
|
"server": {
|
|
21
18
|
"type": "boolean",
|
|
@@ -27,7 +24,11 @@
|
|
|
27
24
|
"enum": ["ts", "js"],
|
|
28
25
|
"description": "NanoForge application language",
|
|
29
26
|
"default": "ts"
|
|
27
|
+
},
|
|
28
|
+
"initFunctions": {
|
|
29
|
+
"type": "boolean",
|
|
30
|
+
"description": "Add init functions to the main application",
|
|
31
|
+
"default": false
|
|
30
32
|
}
|
|
31
|
-
}
|
|
32
|
-
"required": ["name"]
|
|
33
|
+
}
|
|
33
34
|
}
|
|
@@ -2,19 +2,14 @@ import { Rule } from '@angular-devkit/schematics';
|
|
|
2
2
|
|
|
3
3
|
interface DockerSchema {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Target directory for generated Docker files
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
directory: string;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* NanoForge application package manager
|
|
11
11
|
*/
|
|
12
12
|
packageManager: "npm" | "yarn" | "pnpm" | "bun";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Target directory for generated Docker files
|
|
16
|
-
*/
|
|
17
|
-
directory?: string;
|
|
18
13
|
}
|
|
19
14
|
|
|
20
15
|
declare const main: (schema: DockerSchema) => Rule;
|
|
@@ -11,35 +11,13 @@ import {
|
|
|
11
11
|
url
|
|
12
12
|
} from "@angular-devkit/schematics";
|
|
13
13
|
|
|
14
|
-
// src/utils/formatting.ts
|
|
15
|
-
var toKebabCase = /* @__PURE__ */ __name((str) => {
|
|
16
|
-
return str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
17
|
-
}, "toKebabCase");
|
|
18
|
-
|
|
19
|
-
// src/utils/name.ts
|
|
20
|
-
import { basename, parse } from "path";
|
|
21
|
-
var resolvePackageName = /* @__PURE__ */ __name((path) => {
|
|
22
|
-
const { base: baseFilename, dir: dirname } = parse(path);
|
|
23
|
-
if (baseFilename === ".") {
|
|
24
|
-
return basename(process.cwd());
|
|
25
|
-
}
|
|
26
|
-
if (dirname.match(/^@[^\s]/)) {
|
|
27
|
-
return `${dirname}/${baseFilename}`;
|
|
28
|
-
}
|
|
29
|
-
return baseFilename;
|
|
30
|
-
}, "resolvePackageName");
|
|
31
|
-
|
|
32
14
|
// src/defaults.ts
|
|
33
|
-
var DEFAULT_APP_NAME = "nanoforge-app";
|
|
34
15
|
var DEFAULT_PACKAGE_MANAGER = "npm";
|
|
35
16
|
|
|
36
17
|
// src/libs/docker/docker.factory.ts
|
|
37
18
|
var transform = /* @__PURE__ */ __name((schema) => {
|
|
38
|
-
const name = resolvePackageName(toKebabCase(schema.name?.toString() ?? DEFAULT_APP_NAME));
|
|
39
19
|
return {
|
|
40
|
-
|
|
41
|
-
packageManager: schema.packageManager ?? DEFAULT_PACKAGE_MANAGER,
|
|
42
|
-
directory: schema.directory
|
|
20
|
+
packageManager: schema.packageManager ?? DEFAULT_PACKAGE_MANAGER
|
|
43
21
|
};
|
|
44
22
|
}, "transform");
|
|
45
23
|
var generate = /* @__PURE__ */ __name((options, path) => {
|
|
@@ -53,7 +31,7 @@ var generate = /* @__PURE__ */ __name((options, path) => {
|
|
|
53
31
|
}, "generate");
|
|
54
32
|
var main = /* @__PURE__ */ __name((schema) => {
|
|
55
33
|
const options = transform(schema);
|
|
56
|
-
return mergeWith(generate(options, schema.directory
|
|
34
|
+
return mergeWith(generate(options, schema.directory));
|
|
57
35
|
}, "main");
|
|
58
36
|
export {
|
|
59
37
|
main
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/libs/docker/docker.factory.ts","../../../src/
|
|
1
|
+
{"version":3,"sources":["../../../src/libs/docker/docker.factory.ts","../../../src/defaults.ts"],"sourcesContent":["import { type Path, normalize, strings } from \"@angular-devkit/core\";\nimport {\n type Rule,\n type Source,\n apply,\n mergeWith,\n move,\n template,\n url,\n} from \"@angular-devkit/schematics\";\n\nimport { DEFAULT_PACKAGE_MANAGER } from \"~/defaults\";\n\nimport { type DockerOptions } from \"./docker.options\";\nimport { type DockerSchema } from \"./docker.schema\";\n\nconst transform = (schema: DockerSchema): DockerOptions => {\n return {\n packageManager: schema.packageManager ?? DEFAULT_PACKAGE_MANAGER,\n };\n};\n\nconst generate = (options: DockerOptions, path: string): Source => {\n return apply(url(\"./files\" as Path), [\n template({\n ...strings,\n ...options,\n }),\n move(normalize(path)),\n ]);\n};\n\nexport const main = (schema: DockerSchema): Rule => {\n const options = transform(schema);\n return mergeWith(generate(options, schema.directory));\n};\n","export const DEFAULT_APP_NAME = \"nanoforge-app\";\nexport const DEFAULT_VERSION = \"0.0.0\";\nexport const DEFAULT_AUTHOR = \"\";\nexport const DEFAULT_DESCRIPTION = \"\";\nexport const DEFAULT_LANGUAGE = \"ts\";\nexport const DEFAULT_PACKAGE_MANAGER = \"npm\";\n"],"mappings":";;;;AAAA,SAAoB,WAAW,eAAe;AAC9C;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACJA,IAAM,0BAA0B;;;ADWvC,IAAM,YAAY,wBAAC,WAAwC;AACzD,SAAO;AAAA,IACL,gBAAgB,OAAO,kBAAkB;AAAA,EAC3C;AACF,GAJkB;AAMlB,IAAM,WAAW,wBAAC,SAAwB,SAAyB;AACjE,SAAO,MAAM,IAAI,SAAiB,GAAG;AAAA,IACnC,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,IACL,CAAC;AAAA,IACD,KAAK,UAAU,IAAI,CAAC;AAAA,EACtB,CAAC;AACH,GARiB;AAUV,IAAM,OAAO,wBAAC,WAA+B;AAClD,QAAM,UAAU,UAAU,MAAM;AAChC,SAAO,UAAU,SAAS,SAAS,OAAO,SAAS,CAAC;AACtD,GAHoB;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
node_modules
|
|
1
|
+
node_modules/
|
|
@@ -1,36 +1,22 @@
|
|
|
1
|
-
<% if (packageManager === 'bun') { %>
|
|
2
|
-
FROM oven/bun:1.3
|
|
3
|
-
<% } else { %>
|
|
4
|
-
FROM node:25-alpine
|
|
5
|
-
<% } %>
|
|
6
|
-
|
|
1
|
+
<% if (packageManager === 'bun') { %>FROM oven/bun:1.3<% } else { %>FROM node:25-slim<% } %>
|
|
7
2
|
<% if (packageManager === 'pnpm') { %>
|
|
8
3
|
ENV PNPM_HOME="/pnpm"
|
|
9
4
|
ENV PATH="$PNPM_HOME:$PATH"
|
|
10
5
|
RUN npm install -g pnpm
|
|
11
|
-
<% } %>
|
|
12
|
-
|
|
13
|
-
<% if (packageManager === 'yarn') { %>
|
|
6
|
+
<% } %><% if (packageManager === 'yarn') { %>
|
|
14
7
|
RUN npm install -g yarn
|
|
15
8
|
<% } %>
|
|
16
|
-
|
|
17
9
|
WORKDIR /app
|
|
10
|
+
|
|
18
11
|
COPY package.json ./
|
|
19
|
-
<% if (packageManager === 'npm') { %>
|
|
20
|
-
COPY
|
|
21
|
-
<% } else if (packageManager === '
|
|
22
|
-
COPY
|
|
23
|
-
<% } else if (packageManager === 'pnpm') { %>
|
|
24
|
-
COPY pnpm-lock.yaml ./
|
|
25
|
-
<% } else if (packageManager === 'bun') { %>
|
|
26
|
-
COPY bun.lock ./
|
|
12
|
+
<% if (packageManager === 'npm') { %>COPY package-lock.json ./
|
|
13
|
+
<% } else if (packageManager === 'yarn') { %>COPY yarn.lock ./
|
|
14
|
+
<% } else if (packageManager === 'pnpm') { %>COPY pnpm-lock.yaml ./
|
|
15
|
+
<% } else if (packageManager === 'bun') { %>COPY bun.lock ./
|
|
27
16
|
<% } %>
|
|
28
|
-
<% if (packageManager === 'npm') { %>
|
|
29
|
-
RUN
|
|
30
|
-
<% }
|
|
31
|
-
RUN pnpm install --frozen-lockfile --allow-build=bun
|
|
32
|
-
<% } else { %>
|
|
33
|
-
RUN <%= packageManager %> install --frozen-lockfile
|
|
17
|
+
<% if (packageManager === 'npm') { %>RUN npm install --no-lockfile
|
|
18
|
+
<% } else if (packageManager === 'pnpm') { %>RUN pnpm install --frozen-lockfile --allow-build=bun
|
|
19
|
+
<% } else { %>RUN <%= packageManager %> install --frozen-lockfile
|
|
34
20
|
<% } %>
|
|
35
21
|
COPY . .
|
|
36
22
|
|
|
@@ -4,25 +4,16 @@
|
|
|
4
4
|
"title": "NanoForge Base Docker Options Schema",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"properties": {
|
|
7
|
-
"
|
|
7
|
+
"directory": {
|
|
8
8
|
"type": "string",
|
|
9
|
-
"description": "
|
|
10
|
-
"
|
|
11
|
-
"$source": "argv",
|
|
12
|
-
"index": 0
|
|
13
|
-
},
|
|
14
|
-
"x-prompt": "What name would you like to use for the new project ?"
|
|
9
|
+
"description": "NanoForge application destination directory",
|
|
10
|
+
"default": "."
|
|
15
11
|
},
|
|
16
12
|
"packageManager": {
|
|
17
13
|
"type": "string",
|
|
18
14
|
"enum": ["npm", "yarn", "pnpm", "bun"],
|
|
19
15
|
"description": "NanoForge application package manager",
|
|
20
16
|
"default": "npm"
|
|
21
|
-
},
|
|
22
|
-
"directory": {
|
|
23
|
-
"type": "string",
|
|
24
|
-
"description": "NanoForge application destination directory"
|
|
25
17
|
}
|
|
26
|
-
}
|
|
27
|
-
"required": ["name"]
|
|
18
|
+
}
|
|
28
19
|
}
|
|
@@ -46,27 +46,33 @@ export default ExampleComponent.name;
|
|
|
46
46
|
export const EDITOR_COMPONENT_MANIFEST = {
|
|
47
47
|
name: "Example",
|
|
48
48
|
description: "Example component description",
|
|
49
|
-
params:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
49
|
+
params: [
|
|
50
|
+
[
|
|
51
|
+
{
|
|
52
|
+
type: "string",
|
|
53
|
+
name: "paramA",
|
|
54
|
+
description: "Param A description",
|
|
55
|
+
example: "Example value",
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
{
|
|
60
|
+
type: "number",
|
|
61
|
+
name: "paramB",
|
|
62
|
+
description: "Param B description",
|
|
63
|
+
example: 3,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
{
|
|
68
|
+
type: "boolean",
|
|
69
|
+
name: "paramC",
|
|
70
|
+
description: "Param C description",
|
|
71
|
+
example: true,
|
|
72
|
+
default: false,
|
|
73
|
+
// Not required because it has a default value
|
|
74
|
+
optional: true,
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
],
|
|
72
78
|
};
|
|
@@ -12,7 +12,7 @@ import { ExampleComponent } from "../components/example.component";
|
|
|
12
12
|
* @param {Registry} registry - ECS registry instance
|
|
13
13
|
* @param {Context} ctx - Nanoforge <%= part %> instance
|
|
14
14
|
*/
|
|
15
|
-
export const exampleSystem = (registry
|
|
15
|
+
export const exampleSystem = (registry, ctx) => {
|
|
16
16
|
const entities = registry.getZipper([ExampleComponent]);
|
|
17
17
|
|
|
18
18
|
entities.forEach((entity) => {
|
|
@@ -29,27 +29,33 @@ export default ExampleComponent.name;
|
|
|
29
29
|
export const EDITOR_COMPONENT_MANIFEST: EditorComponentManifest = {
|
|
30
30
|
name: "Example",
|
|
31
31
|
description: "Example component description",
|
|
32
|
-
params:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
32
|
+
params: [
|
|
33
|
+
[
|
|
34
|
+
{
|
|
35
|
+
type: "string",
|
|
36
|
+
name: "paramA",
|
|
37
|
+
description: "Param A description",
|
|
38
|
+
example: "Example value",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
{
|
|
43
|
+
type: "number",
|
|
44
|
+
name: "paramB",
|
|
45
|
+
description: "Param B description",
|
|
46
|
+
example: 3,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
[
|
|
50
|
+
{
|
|
51
|
+
type: "boolean",
|
|
52
|
+
name: "paramC",
|
|
53
|
+
description: "Param C description",
|
|
54
|
+
example: true,
|
|
55
|
+
default: false,
|
|
56
|
+
// Not required because it has a default value
|
|
57
|
+
optional: true,
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
],
|
|
55
61
|
};
|
|
@@ -2,34 +2,29 @@ import { Rule } from '@angular-devkit/schematics';
|
|
|
2
2
|
|
|
3
3
|
interface PartBaseSchema {
|
|
4
4
|
/**
|
|
5
|
-
* NanoForge application
|
|
5
|
+
* NanoForge application destination directory
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
directory: string;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* The part of the application to generate
|
|
11
11
|
*/
|
|
12
12
|
part: "client" | "server";
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
* NanoForge application destination directory
|
|
16
|
-
*/
|
|
17
|
-
directory?: string;
|
|
18
|
-
|
|
19
14
|
/**
|
|
20
15
|
* NanoForge Application language
|
|
21
16
|
*/
|
|
22
|
-
language
|
|
17
|
+
language: "js" | "ts";
|
|
23
18
|
|
|
24
19
|
/**
|
|
25
20
|
* Add init functions to the application
|
|
26
21
|
*/
|
|
27
|
-
initFunctions
|
|
22
|
+
initFunctions: boolean;
|
|
28
23
|
|
|
29
24
|
/**
|
|
30
25
|
* Configure a server for the application
|
|
31
26
|
*/
|
|
32
|
-
server
|
|
27
|
+
server: boolean;
|
|
33
28
|
}
|
|
34
29
|
|
|
35
30
|
declare const main: (schema: PartBaseSchema) => Rule;
|
|
@@ -11,47 +11,19 @@ import {
|
|
|
11
11
|
template,
|
|
12
12
|
url
|
|
13
13
|
} from "@angular-devkit/schematics";
|
|
14
|
-
|
|
15
|
-
// src/utils/formatting.ts
|
|
16
|
-
var toKebabCase = /* @__PURE__ */ __name((str) => {
|
|
17
|
-
return str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
|
|
18
|
-
}, "toKebabCase");
|
|
19
|
-
|
|
20
|
-
// src/utils/name.ts
|
|
21
|
-
import { basename, parse } from "path";
|
|
22
|
-
var resolvePackageName = /* @__PURE__ */ __name((path) => {
|
|
23
|
-
const { base: baseFilename, dir: dirname } = parse(path);
|
|
24
|
-
if (baseFilename === ".") {
|
|
25
|
-
return basename(process.cwd());
|
|
26
|
-
}
|
|
27
|
-
if (dirname.match(/^@[^\s]/)) {
|
|
28
|
-
return `${dirname}/${baseFilename}`;
|
|
29
|
-
}
|
|
30
|
-
return baseFilename;
|
|
31
|
-
}, "resolvePackageName");
|
|
32
|
-
|
|
33
|
-
// src/defaults.ts
|
|
34
|
-
var DEFAULT_APP_NAME = "nanoforge-app";
|
|
35
|
-
var DEFAULT_LANGUAGE = "ts";
|
|
36
|
-
|
|
37
|
-
// src/libs/part-base/part-base.factory.ts
|
|
38
14
|
var transform = /* @__PURE__ */ __name((schema) => {
|
|
39
|
-
const name = resolvePackageName(toKebabCase(schema.name?.toString() ?? DEFAULT_APP_NAME));
|
|
40
15
|
return {
|
|
41
|
-
name,
|
|
42
16
|
part: schema.part,
|
|
43
17
|
server: schema.server,
|
|
44
18
|
appClass: schema.part === "client" ? "NanoforgeClient" : "NanoforgeServer",
|
|
45
|
-
|
|
46
|
-
initFunctions: schema.initFunctions ?? false
|
|
19
|
+
nanoforgeFolder: ".nanoforge"
|
|
47
20
|
};
|
|
48
21
|
}, "transform");
|
|
49
|
-
var generate = /* @__PURE__ */ __name((options, path) => {
|
|
22
|
+
var generate = /* @__PURE__ */ __name((options, path, initFunctions, language) => {
|
|
50
23
|
const rules = [
|
|
51
24
|
template({
|
|
52
25
|
...strings,
|
|
53
|
-
...options
|
|
54
|
-
nanoforgeFolder: ".nanoforge"
|
|
26
|
+
...options
|
|
55
27
|
}),
|
|
56
28
|
move(normalize(path)),
|
|
57
29
|
filter((path2) => {
|
|
@@ -59,12 +31,12 @@ var generate = /* @__PURE__ */ __name((options, path) => {
|
|
|
59
31
|
return splited.at(-2) !== ".nanoforge" || splited.at(-1) === `${options.part}.save.json`;
|
|
60
32
|
})
|
|
61
33
|
];
|
|
62
|
-
if (!
|
|
63
|
-
return apply(url(join("./files",
|
|
34
|
+
if (!initFunctions) rules.push(filter((path2) => path2.split("/").at(-2) !== "init"));
|
|
35
|
+
return apply(url(join("./files", language)), rules);
|
|
64
36
|
}, "generate");
|
|
65
37
|
var main = /* @__PURE__ */ __name((schema) => {
|
|
66
38
|
const options = transform(schema);
|
|
67
|
-
return mergeWith(generate(options, schema.directory
|
|
39
|
+
return mergeWith(generate(options, schema.directory, schema.initFunctions, schema.language));
|
|
68
40
|
}, "main");
|
|
69
41
|
export {
|
|
70
42
|
main
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/libs/part-base/part-base.factory.ts"
|
|
1
|
+
{"version":3,"sources":["../../../src/libs/part-base/part-base.factory.ts"],"sourcesContent":["import { type Path, join, normalize, strings } from \"@angular-devkit/core\";\nimport {\n type Rule,\n type Source,\n apply,\n filter,\n mergeWith,\n move,\n template,\n url,\n} from \"@angular-devkit/schematics\";\n\nimport { type PartBaseOptions } from \"./part-base.options\";\nimport { type PartBaseSchema } from \"./part-base.schema\";\n\nconst transform = (schema: PartBaseSchema): PartBaseOptions => {\n return {\n part: schema.part,\n server: schema.server,\n appClass: schema.part === \"client\" ? \"NanoforgeClient\" : \"NanoforgeServer\",\n nanoforgeFolder: \".nanoforge\",\n };\n};\n\nconst generate = (\n options: PartBaseOptions,\n path: string,\n initFunctions: boolean,\n language: \"ts\" | \"js\",\n): Source => {\n const rules = [\n template({\n ...strings,\n ...options,\n }),\n move(normalize(path)),\n filter((path) => {\n const splited = path.split(\"/\");\n return splited.at(-2) !== \".nanoforge\" || splited.at(-1) === `${options.part}.save.json`;\n }),\n ];\n if (!initFunctions) rules.push(filter((path) => path.split(\"/\").at(-2) !== \"init\"));\n\n return apply(url(join(\"./files\" as Path, language)), rules);\n};\n\nexport const main = (schema: PartBaseSchema): Rule => {\n const options = transform(schema);\n\n return mergeWith(generate(options, schema.directory, schema.initFunctions, schema.language));\n};\n"],"mappings":";;;;AAAA,SAAoB,MAAM,WAAW,eAAe;AACpD;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKP,IAAM,YAAY,wBAAC,WAA4C;AAC7D,SAAO;AAAA,IACL,MAAM,OAAO;AAAA,IACb,QAAQ,OAAO;AAAA,IACf,UAAU,OAAO,SAAS,WAAW,oBAAoB;AAAA,IACzD,iBAAiB;AAAA,EACnB;AACF,GAPkB;AASlB,IAAM,WAAW,wBACf,SACA,MACA,eACA,aACW;AACX,QAAM,QAAQ;AAAA,IACZ,SAAS;AAAA,MACP,GAAG;AAAA,MACH,GAAG;AAAA,IACL,CAAC;AAAA,IACD,KAAK,UAAU,IAAI,CAAC;AAAA,IACpB,OAAO,CAACA,UAAS;AACf,YAAM,UAAUA,MAAK,MAAM,GAAG;AAC9B,aAAO,QAAQ,GAAG,EAAE,MAAM,gBAAgB,QAAQ,GAAG,EAAE,MAAM,GAAG,QAAQ,IAAI;AAAA,IAC9E,CAAC;AAAA,EACH;AACA,MAAI,CAAC,cAAe,OAAM,KAAK,OAAO,CAACA,UAASA,MAAK,MAAM,GAAG,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAElF,SAAO,MAAM,IAAI,KAAK,WAAmB,QAAQ,CAAC,GAAG,KAAK;AAC5D,GApBiB;AAsBV,IAAM,OAAO,wBAAC,WAAiC;AACpD,QAAM,UAAU,UAAU,MAAM;AAEhC,SAAO,UAAU,SAAS,SAAS,OAAO,WAAW,OAAO,eAAe,OAAO,QAAQ,CAAC;AAC7F,GAJoB;","names":["path"]}
|