@nanoforge-dev/schematics 2.1.3 → 2.1.4-beta.131e794
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 +3 -0
- package/dist/index.cjs +15 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -15
- package/dist/index.js.map +1 -1
- package/dist/libs/application/application.factory.d.ts +10 -13
- package/dist/libs/application/application.factory.d.ts.map +1 -0
- package/dist/libs/application/application.factory.js +52 -68
- package/dist/libs/application/application.factory.js.map +1 -1
- package/dist/libs/application/files/js/README.md +165 -0
- package/dist/libs/application/files/js/__dot__env +6 -0
- package/dist/libs/application/files/js/__dot__gitignore +134 -0
- package/dist/libs/application/files/ts/README.md +165 -0
- package/dist/libs/application/files/ts/__dot__env +6 -0
- package/dist/libs/application/files/ts/__dot__gitignore +134 -0
- package/dist/libs/application/schema.json +5 -0
- package/dist/libs/component/component.factory.d.ts +6 -6
- package/dist/libs/component/component.factory.d.ts.map +1 -0
- package/dist/libs/component/component.factory.js +32 -47
- package/dist/libs/component/component.factory.js.map +1 -1
- package/dist/libs/component/files/js/__fileName__.component.js +21 -27
- package/dist/libs/component/files/ts/__fileName__.component.ts +21 -27
- package/dist/libs/configuration/configuration.factory.d.ts +6 -7
- package/dist/libs/configuration/configuration.factory.d.ts.map +1 -0
- package/dist/libs/configuration/configuration.factory.js +91 -133
- package/dist/libs/configuration/configuration.factory.js.map +1 -1
- package/dist/libs/docker/docker.factory.d.ts +6 -4
- package/dist/libs/docker/docker.factory.d.ts.map +1 -0
- package/dist/libs/docker/docker.factory.js +17 -36
- package/dist/libs/docker/docker.factory.js.map +1 -1
- package/dist/libs/part-base/part-base.factory.d.ts +6 -7
- package/dist/libs/part-base/part-base.factory.d.ts.map +1 -0
- package/dist/libs/part-base/part-base.factory.js +30 -41
- package/dist/libs/part-base/part-base.factory.js.map +1 -1
- package/dist/libs/part-main/part-main.factory.d.ts +6 -9
- package/dist/libs/part-main/part-main.factory.d.ts.map +1 -0
- package/dist/libs/part-main/part-main.factory.js +228 -260
- package/dist/libs/part-main/part-main.factory.js.map +1 -1
- package/dist/libs/system/system.factory.d.ts +6 -6
- package/dist/libs/system/system.factory.d.ts.map +1 -0
- package/dist/libs/system/system.factory.js +32 -50
- package/dist/libs/system/system.factory.js.map +1 -1
- package/package.json +18 -18
package/README.md
CHANGED
|
@@ -42,6 +42,9 @@ This repository provide multiples schematics, usable with Angular Devkit schemat
|
|
|
42
42
|
- `configuration` : Template of `nanoforge.config.json` with premade fields
|
|
43
43
|
- `part-base` : Base of Nanoforge client or server
|
|
44
44
|
- `part-main` : Client or server `main.ts` from a config
|
|
45
|
+
- `component` : ECS component class for a client or server part
|
|
46
|
+
- `system` : ECS system function for a client or server part
|
|
47
|
+
- `docker` : Dockerfile and `.dockerignore` tailored to your package manager
|
|
45
48
|
|
|
46
49
|
## Contributing
|
|
47
50
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,48 +1,17 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/defaults.ts
|
|
3
|
+
const DEFAULT_APP_NAME = "nanoforge-app";
|
|
4
|
+
const DEFAULT_VERSION = "0.0.0";
|
|
5
|
+
const DEFAULT_AUTHOR = "";
|
|
6
|
+
const DEFAULT_DESCRIPTION = "";
|
|
7
|
+
const DEFAULT_LANGUAGE = "ts";
|
|
8
|
+
const DEFAULT_PACKAGE_MANAGER = "npm";
|
|
9
|
+
//#endregion
|
|
10
|
+
exports.DEFAULT_APP_NAME = DEFAULT_APP_NAME;
|
|
11
|
+
exports.DEFAULT_AUTHOR = DEFAULT_AUTHOR;
|
|
12
|
+
exports.DEFAULT_DESCRIPTION = DEFAULT_DESCRIPTION;
|
|
13
|
+
exports.DEFAULT_LANGUAGE = DEFAULT_LANGUAGE;
|
|
14
|
+
exports.DEFAULT_PACKAGE_MANAGER = DEFAULT_PACKAGE_MANAGER;
|
|
15
|
+
exports.DEFAULT_VERSION = DEFAULT_VERSION;
|
|
19
16
|
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
DEFAULT_APP_NAME: () => DEFAULT_APP_NAME,
|
|
24
|
-
DEFAULT_AUTHOR: () => DEFAULT_AUTHOR,
|
|
25
|
-
DEFAULT_DESCRIPTION: () => DEFAULT_DESCRIPTION,
|
|
26
|
-
DEFAULT_LANGUAGE: () => DEFAULT_LANGUAGE,
|
|
27
|
-
DEFAULT_PACKAGE_MANAGER: () => DEFAULT_PACKAGE_MANAGER,
|
|
28
|
-
DEFAULT_VERSION: () => DEFAULT_VERSION
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(index_exports);
|
|
31
|
-
|
|
32
|
-
// src/defaults.ts
|
|
33
|
-
var DEFAULT_APP_NAME = "nanoforge-app";
|
|
34
|
-
var DEFAULT_VERSION = "0.0.0";
|
|
35
|
-
var DEFAULT_AUTHOR = "";
|
|
36
|
-
var DEFAULT_DESCRIPTION = "";
|
|
37
|
-
var DEFAULT_LANGUAGE = "ts";
|
|
38
|
-
var DEFAULT_PACKAGE_MANAGER = "npm";
|
|
39
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
-
0 && (module.exports = {
|
|
41
|
-
DEFAULT_APP_NAME,
|
|
42
|
-
DEFAULT_AUTHOR,
|
|
43
|
-
DEFAULT_DESCRIPTION,
|
|
44
|
-
DEFAULT_LANGUAGE,
|
|
45
|
-
DEFAULT_PACKAGE_MANAGER,
|
|
46
|
-
DEFAULT_VERSION
|
|
47
|
-
});
|
|
48
17
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/defaults.ts"],"sourcesContent":["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,MAAa,mBAAmB;AAChC,MAAa,kBAAkB;AAC/B,MAAa,iBAAiB;AAC9B,MAAa,sBAAsB;AACnC,MAAa,mBAAmB;AAChC,MAAa,0BAA0B"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
//#region src/defaults.d.ts
|
|
1
2
|
declare const DEFAULT_APP_NAME = "nanoforge-app";
|
|
2
3
|
declare const DEFAULT_VERSION = "0.0.0";
|
|
3
4
|
declare const DEFAULT_AUTHOR = "";
|
|
4
5
|
declare const DEFAULT_DESCRIPTION = "";
|
|
5
6
|
declare const DEFAULT_LANGUAGE = "ts";
|
|
6
7
|
declare const DEFAULT_PACKAGE_MANAGER = "npm";
|
|
7
|
-
|
|
8
|
+
//#endregion
|
|
8
9
|
export { DEFAULT_APP_NAME, DEFAULT_AUTHOR, DEFAULT_DESCRIPTION, DEFAULT_LANGUAGE, DEFAULT_PACKAGE_MANAGER, DEFAULT_VERSION };
|
|
10
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/defaults.ts"],"mappings":";cAAa,gBAAA;AAAA,cACA,eAAA;AAAA,cACA,cAAA;AAAA,cACA,mBAAA;AAAA,cACA,gBAAA;AAAA,cACA,uBAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
//#region src/defaults.d.ts
|
|
1
2
|
declare const DEFAULT_APP_NAME = "nanoforge-app";
|
|
2
3
|
declare const DEFAULT_VERSION = "0.0.0";
|
|
3
4
|
declare const DEFAULT_AUTHOR = "";
|
|
4
5
|
declare const DEFAULT_DESCRIPTION = "";
|
|
5
6
|
declare const DEFAULT_LANGUAGE = "ts";
|
|
6
7
|
declare const DEFAULT_PACKAGE_MANAGER = "npm";
|
|
7
|
-
|
|
8
|
+
//#endregion
|
|
8
9
|
export { DEFAULT_APP_NAME, DEFAULT_AUTHOR, DEFAULT_DESCRIPTION, DEFAULT_LANGUAGE, DEFAULT_PACKAGE_MANAGER, DEFAULT_VERSION };
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/defaults.ts"],"mappings":";cAAa,gBAAA;AAAA,cACA,eAAA;AAAA,cACA,cAAA;AAAA,cACA,mBAAA;AAAA,cACA,gBAAA;AAAA,cACA,uBAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
DEFAULT_DESCRIPTION,
|
|
12
|
-
DEFAULT_LANGUAGE,
|
|
13
|
-
DEFAULT_PACKAGE_MANAGER,
|
|
14
|
-
DEFAULT_VERSION
|
|
15
|
-
};
|
|
1
|
+
//#region src/defaults.ts
|
|
2
|
+
const DEFAULT_APP_NAME = "nanoforge-app";
|
|
3
|
+
const DEFAULT_VERSION = "0.0.0";
|
|
4
|
+
const DEFAULT_AUTHOR = "";
|
|
5
|
+
const DEFAULT_DESCRIPTION = "";
|
|
6
|
+
const DEFAULT_LANGUAGE = "ts";
|
|
7
|
+
const DEFAULT_PACKAGE_MANAGER = "npm";
|
|
8
|
+
//#endregion
|
|
9
|
+
export { DEFAULT_APP_NAME, DEFAULT_AUTHOR, DEFAULT_DESCRIPTION, DEFAULT_LANGUAGE, DEFAULT_PACKAGE_MANAGER, DEFAULT_VERSION };
|
|
10
|
+
|
|
16
11
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["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":";
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/defaults.ts"],"sourcesContent":["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,MAAa,mBAAmB;AAChC,MAAa,kBAAkB;AAC/B,MAAa,iBAAiB;AAC9B,MAAa,sBAAsB;AACnC,MAAa,mBAAmB;AAChC,MAAa,0BAA0B"}
|
|
@@ -1,62 +1,59 @@
|
|
|
1
|
-
import { Rule } from
|
|
1
|
+
import { Rule } from "@angular-devkit/schematics";
|
|
2
2
|
|
|
3
|
+
//#region src/libs/application/application.schema.d.ts
|
|
3
4
|
interface ApplicationSchema {
|
|
4
5
|
/**
|
|
5
6
|
* NanoForge application name
|
|
6
7
|
*/
|
|
7
8
|
name: string;
|
|
8
|
-
|
|
9
9
|
/**
|
|
10
10
|
* NanoForge application version
|
|
11
11
|
*/
|
|
12
12
|
version?: string;
|
|
13
|
-
|
|
14
13
|
/**
|
|
15
14
|
* NanoForge application author
|
|
16
15
|
*/
|
|
17
16
|
author?: string;
|
|
18
|
-
|
|
19
17
|
/**
|
|
20
18
|
* NanoForge application description
|
|
21
19
|
*/
|
|
22
20
|
description?: string;
|
|
23
|
-
|
|
24
21
|
/**
|
|
25
22
|
* NanoForge application destination directory
|
|
26
23
|
*/
|
|
27
24
|
directory?: string;
|
|
28
|
-
|
|
29
25
|
/**
|
|
30
26
|
* NanoForge Application language
|
|
31
27
|
*/
|
|
32
28
|
language?: "js" | "ts";
|
|
33
|
-
|
|
34
29
|
/**
|
|
35
30
|
* With strict mode (TypeScript or JavaScript but only on compatible editor)
|
|
36
31
|
*/
|
|
37
32
|
strict?: boolean;
|
|
38
|
-
|
|
39
33
|
/**
|
|
40
34
|
* Generate lint files
|
|
41
35
|
*/
|
|
42
36
|
lint?: boolean;
|
|
43
|
-
|
|
44
37
|
/**
|
|
45
38
|
* The used package manager
|
|
46
39
|
*/
|
|
47
40
|
packageManager?: "npm" | "yarn" | "pnpm" | "bun";
|
|
48
|
-
|
|
49
41
|
/**
|
|
50
42
|
* Configure a server for the application
|
|
51
43
|
*/
|
|
52
44
|
server?: boolean;
|
|
53
|
-
|
|
54
45
|
/**
|
|
55
46
|
* Add editor dependencies
|
|
56
47
|
*/
|
|
57
48
|
editor: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Add init functions to the application
|
|
51
|
+
*/
|
|
52
|
+
initFunctions: boolean;
|
|
58
53
|
}
|
|
59
|
-
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/libs/application/application.factory.d.ts
|
|
60
56
|
declare const main: (schema: ApplicationSchema) => Rule;
|
|
61
|
-
|
|
57
|
+
//#endregion
|
|
62
58
|
export { main };
|
|
59
|
+
//# sourceMappingURL=application.factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application.factory.d.ts","names":["name","version","author","description","directory","language","strict","lint","packageManager","server","editor","initFunctions"],"sources":["../../../src/libs/application/application.schema.d.ts","../../../src/libs/application/application.factory.ts"],"mappings":";;;UAAiB,iBAAA;;;AAAjB;EAIEA,IAAAA;EAJgC;;;EAShCC,OAAAA;EAeAG;;;EAVAF,MAAAA;EAmCAO;;;EA9BAN,WAAAA;;;;EAKAC,SAAAA;;;;EAKAC,QAAAA;ECqDD;AAAA;;EDhDCC,MAAAA;;;;EAKAC,IAAAA;;;;EAKAC,cAAAA;;;;EAKAC,MAAAA;;;;EAKAC,MAAAA;;;;EAKAC,aAAAA;AAAAA;;;cCJW,IAAA,GAAQ,MAAA,EAAQ,iBAAA,KAAoB,IA2BhD"}
|
|
@@ -1,72 +1,56 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/libs/application/application.factory.ts
|
|
5
1
|
import { join, normalize, strings } from "@angular-devkit/core";
|
|
6
|
-
import {
|
|
7
|
-
apply,
|
|
8
|
-
mergeWith,
|
|
9
|
-
move,
|
|
10
|
-
renameTemplateFiles,
|
|
11
|
-
template,
|
|
12
|
-
url
|
|
13
|
-
} from "@angular-devkit/schematics";
|
|
2
|
+
import { apply, mergeWith, move, renameTemplateFiles, template, url } from "@angular-devkit/schematics";
|
|
14
3
|
import { firstValueFrom } from "rxjs";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
language: schema.language ?? DEFAULT_LANGUAGE,
|
|
32
|
-
strict: schema.strict ?? true,
|
|
33
|
-
lint: schema.lint ?? true,
|
|
34
|
-
packageManager: schema.packageManager ?? DEFAULT_PACKAGE_MANAGER,
|
|
35
|
-
server: schema.server ?? false,
|
|
36
|
-
editor: schema.editor ?? false
|
|
37
|
-
};
|
|
38
|
-
}, "transform");
|
|
39
|
-
var generate = /* @__PURE__ */ __name((options, path) => {
|
|
40
|
-
return apply(url(join("./files", options.language)), [
|
|
41
|
-
template({
|
|
42
|
-
...strings,
|
|
43
|
-
...options
|
|
44
|
-
}),
|
|
45
|
-
renameTemplateFiles(),
|
|
46
|
-
move(normalize(path))
|
|
47
|
-
]);
|
|
48
|
-
}, "generate");
|
|
49
|
-
var main = /* @__PURE__ */ __name((schema) => {
|
|
50
|
-
const options = transform(schema);
|
|
51
|
-
const path = schema.directory ?? options.name;
|
|
52
|
-
return async (baseTree, context) => {
|
|
53
|
-
let tree = await mergeWith(generate(options, path))(baseTree, context);
|
|
54
|
-
if (!tree) return tree;
|
|
55
|
-
if (!("delete" in tree)) {
|
|
56
|
-
if (typeof tree === "function") return tree;
|
|
57
|
-
tree = await firstValueFrom(tree);
|
|
58
|
-
}
|
|
59
|
-
if (!options.lint) {
|
|
60
|
-
const basePath = join("/", path);
|
|
61
|
-
tree.delete(join(basePath, "eslint.config.js"));
|
|
62
|
-
tree.delete(join(basePath, "prettier.config.js"));
|
|
63
|
-
tree.delete(join(basePath, ".prettierignore"));
|
|
64
|
-
if (options.language === "js") tree.delete(join(basePath, "jsconfig.json"));
|
|
65
|
-
}
|
|
66
|
-
return tree;
|
|
67
|
-
};
|
|
68
|
-
}, "main");
|
|
69
|
-
export {
|
|
70
|
-
main
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/libs/application/application.factory.ts
|
|
6
|
+
const transform = (schema) => {
|
|
7
|
+
return {
|
|
8
|
+
name: schema.name ?? "nanoforge-app",
|
|
9
|
+
version: schema.version ?? "0.0.0",
|
|
10
|
+
author: schema.author ?? "",
|
|
11
|
+
description: schema.description ?? "",
|
|
12
|
+
language: schema.language ?? "ts",
|
|
13
|
+
strict: schema.strict ?? true,
|
|
14
|
+
lint: schema.lint ?? true,
|
|
15
|
+
packageManager: schema.packageManager ?? "npm",
|
|
16
|
+
server: schema.server ?? false,
|
|
17
|
+
editor: schema.editor ?? false,
|
|
18
|
+
initFunctions: schema.initFunctions ?? false
|
|
19
|
+
};
|
|
71
20
|
};
|
|
21
|
+
const generate = (options, path) => {
|
|
22
|
+
return apply(url(join("./files", options.language)), [
|
|
23
|
+
template({
|
|
24
|
+
dot: ".",
|
|
25
|
+
...strings,
|
|
26
|
+
...options
|
|
27
|
+
}),
|
|
28
|
+
renameTemplateFiles(),
|
|
29
|
+
move(normalize(path))
|
|
30
|
+
]);
|
|
31
|
+
};
|
|
32
|
+
const main = (schema) => {
|
|
33
|
+
const options = transform(schema);
|
|
34
|
+
const path = schema.directory ?? options.name;
|
|
35
|
+
return async (baseTree, context) => {
|
|
36
|
+
let tree = await mergeWith(generate(options, path))(baseTree, context);
|
|
37
|
+
if (!tree) return tree;
|
|
38
|
+
if (!("delete" in tree)) {
|
|
39
|
+
if (typeof tree === "function") return tree;
|
|
40
|
+
tree = await firstValueFrom(tree);
|
|
41
|
+
}
|
|
42
|
+
const basePath = join("/", path);
|
|
43
|
+
if (!options.lint) {
|
|
44
|
+
tree.delete(join(basePath, "eslint.config.js"));
|
|
45
|
+
tree.delete(join(basePath, "prettier.config.js"));
|
|
46
|
+
tree.delete(join(basePath, ".prettierignore"));
|
|
47
|
+
if (options.language === "js") tree.delete(join(basePath, "jsconfig.json"));
|
|
48
|
+
}
|
|
49
|
+
if (!options.server) tree.delete(join(basePath, ".env"));
|
|
50
|
+
return tree;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
//#endregion
|
|
54
|
+
export { main };
|
|
55
|
+
|
|
72
56
|
//# sourceMappingURL=application.factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/
|
|
1
|
+
{"version":3,"file":"application.factory.js","names":[],"sources":["../../../src/defaults.ts","../../../src/libs/application/application.factory.ts"],"sourcesContent":["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","import { type Path, join, normalize, strings } from \"@angular-devkit/core\";\nimport {\n type Rule,\n type SchematicContext,\n type Source,\n type Tree,\n apply,\n mergeWith,\n move,\n renameTemplateFiles,\n template,\n url,\n} from \"@angular-devkit/schematics\";\nimport { firstValueFrom } from \"rxjs\";\n\nimport {\n DEFAULT_APP_NAME,\n DEFAULT_AUTHOR,\n DEFAULT_DESCRIPTION,\n DEFAULT_LANGUAGE,\n DEFAULT_PACKAGE_MANAGER,\n DEFAULT_VERSION,\n} from \"~/defaults\";\n\nimport { type ApplicationOptions } from \"./application.options\";\nimport { type ApplicationSchema } from \"./application.schema\";\n\nconst transform = (schema: ApplicationSchema): ApplicationOptions => {\n return {\n name: schema.name ?? DEFAULT_APP_NAME,\n version: schema.version ?? DEFAULT_VERSION,\n author: schema.author ?? DEFAULT_AUTHOR,\n description: schema.description ?? DEFAULT_DESCRIPTION,\n language: schema.language ?? DEFAULT_LANGUAGE,\n strict: schema.strict ?? true,\n lint: schema.lint ?? true,\n packageManager: schema.packageManager ?? DEFAULT_PACKAGE_MANAGER,\n server: schema.server ?? false,\n editor: schema.editor ?? false,\n initFunctions: schema.initFunctions ?? false,\n };\n};\n\nconst generate = (options: ApplicationOptions, path: string): Source => {\n return apply(url(join(\"./files\" as Path, options.language)), [\n template({\n dot: \".\",\n ...strings,\n ...options,\n }),\n renameTemplateFiles(),\n move(normalize(path)),\n ]);\n};\n\nexport const main = (schema: ApplicationSchema): Rule => {\n const options = transform(schema);\n const path = schema.directory ?? options.name;\n\n return async (baseTree: Tree, context: SchematicContext) => {\n let tree = await mergeWith(generate(options, path))(baseTree, context);\n if (!tree) return tree;\n if (!(\"delete\" in tree)) {\n if (typeof tree === \"function\") return tree;\n tree = await firstValueFrom(tree);\n }\n\n const basePath = join(\"/\" as Path, path);\n\n if (!options.lint) {\n tree.delete(join(basePath, \"eslint.config.js\"));\n tree.delete(join(basePath, \"prettier.config.js\"));\n tree.delete(join(basePath, \".prettierignore\"));\n if (options.language === \"js\") tree.delete(join(basePath, \"jsconfig.json\"));\n }\n\n if (!options.server) {\n tree.delete(join(basePath, \".env\"));\n }\n\n return tree;\n };\n};\n"],"mappings":";;;;;AC2BA,MAAM,aAAa,WAAkD;CACnE,OAAO;EACL,MAAM,OAAO,QAAA;EACb,SAAS,OAAO,WAAA;EAChB,QAAQ,OAAO,UAAA;EACf,aAAa,OAAO,eAAA;EACpB,UAAU,OAAO,YAAA;EACjB,QAAQ,OAAO,UAAU;EACzB,MAAM,OAAO,QAAQ;EACrB,gBAAgB,OAAO,kBAAA;EACvB,QAAQ,OAAO,UAAU;EACzB,QAAQ,OAAO,UAAU;EACzB,eAAe,OAAO,iBAAiB;CACzC;AACF;AAEA,MAAM,YAAY,SAA6B,SAAyB;CACtE,OAAO,MAAM,IAAI,KAAK,WAAmB,QAAQ,QAAQ,CAAC,GAAG;EAC3D,SAAS;GACP,KAAK;GACL,GAAG;GACH,GAAG;EACL,CAAC;EACD,oBAAoB;EACpB,KAAK,UAAU,IAAI,CAAC;CACtB,CAAC;AACH;AAEA,MAAa,QAAQ,WAAoC;CACvD,MAAM,UAAU,UAAU,MAAM;CAChC,MAAM,OAAO,OAAO,aAAa,QAAQ;CAEzC,OAAO,OAAO,UAAgB,YAA8B;EAC1D,IAAI,OAAO,MAAM,UAAU,SAAS,SAAS,IAAI,CAAC,EAAE,UAAU,OAAO;EACrE,IAAI,CAAC,MAAM,OAAO;EAClB,IAAI,EAAE,YAAY,OAAO;GACvB,IAAI,OAAO,SAAS,YAAY,OAAO;GACvC,OAAO,MAAM,eAAe,IAAI;EAClC;EAEA,MAAM,WAAW,KAAK,KAAa,IAAI;EAEvC,IAAI,CAAC,QAAQ,MAAM;GACjB,KAAK,OAAO,KAAK,UAAU,kBAAkB,CAAC;GAC9C,KAAK,OAAO,KAAK,UAAU,oBAAoB,CAAC;GAChD,KAAK,OAAO,KAAK,UAAU,iBAAiB,CAAC;GAC7C,IAAI,QAAQ,aAAa,MAAM,KAAK,OAAO,KAAK,UAAU,eAAe,CAAC;EAC5E;EAEA,IAAI,CAAC,QAAQ,QACX,KAAK,OAAO,KAAK,UAAU,MAAM,CAAC;EAGpC,OAAO;CACT;AACF"}
|
|
@@ -1 +1,166 @@
|
|
|
1
1
|
# <%= name %>
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- [Node.js](https://nodejs.org/) 18+
|
|
8
|
+
- Package manager: **<%= packageManager %>**
|
|
9
|
+
- [NanoForge CLI](https://www.npmjs.com/package/@nanoforge-dev/cli): `<%= packageManager %> install -g @nanoforge-dev/cli`
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
<%= packageManager %> install
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Development
|
|
22
|
+
|
|
23
|
+
Start the game in watch mode with hot reload:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
nf dev
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
<% if (editor) { %>Open the visual editor (optional — lets you edit entities, components and systems without touching code):
|
|
30
|
+
```bash
|
|
31
|
+
nf editor
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
<% } %>---
|
|
35
|
+
|
|
36
|
+
## Project structure
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
<%= name %>/
|
|
40
|
+
├── .nanoforge/ # NanoForge internal save files (do not edit manually)
|
|
41
|
+
├── client/ # Client-side code (runs in the browser)
|
|
42
|
+
│ ├── static/ # Static assets
|
|
43
|
+
│ ├── components/ # ECS components
|
|
44
|
+
│ ├── systems/ # ECS systems<% if (initFunctions) { %>
|
|
45
|
+
│ └── init/ # Lifecycle hooks (before-init, after-run, …)<% } %><% if (server) { %>
|
|
46
|
+
├── server/ # Server-side code
|
|
47
|
+
│ ├── static/
|
|
48
|
+
│ ├── components/
|
|
49
|
+
│ ├── systems/<% if (initFunctions) { %>
|
|
50
|
+
│ └── init/<% } %><% } %>
|
|
51
|
+
├── package.json
|
|
52
|
+
├── jsconfig.json
|
|
53
|
+
└── nanoforge.config.json # Game configuration
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Modifying the game
|
|
59
|
+
|
|
60
|
+
### Add a component
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
nf generate component <name> --part client
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
A component is a plain class that holds data for an entity. Edit the generated file in `client/components/`:
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
export class MyComponent {
|
|
70
|
+
constructor(speed) {
|
|
71
|
+
this.speed = speed;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default MyComponent.name;
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Add a system
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
nf generate system <name> --part client
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
A system is a function that runs every tick and operates on entities that have specific components. Edit the generated file in `client/systems/`:
|
|
85
|
+
|
|
86
|
+
```js
|
|
87
|
+
import { MyComponent } from "../components/my.component.js";
|
|
88
|
+
|
|
89
|
+
export const mySystem = (registry, ctx) => {
|
|
90
|
+
const entities = registry.getZipper([MyComponent]);
|
|
91
|
+
|
|
92
|
+
entities.forEach((entity) => {
|
|
93
|
+
entity.MyComponent.speed += 1;
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default mySystem.name;
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
<% if (server) { %>
|
|
101
|
+
### Server-side code
|
|
102
|
+
|
|
103
|
+
Server components and systems live in `server/` and are imported from `@nanoforge-dev/ecs-server`. They follow the same pattern as the client side.
|
|
104
|
+
|
|
105
|
+
Configure the server connection in `.env`:
|
|
106
|
+
|
|
107
|
+
| Variable | Default | Description |
|
|
108
|
+
|---------------------------------------|-------------|---------------------------------|
|
|
109
|
+
| `NANOFORGE_CLIENT_SERVER_ADDRESS` | `127.0.0.1` | Server address (client-side) |
|
|
110
|
+
| `NANOFORGE_CLIENT_SERVER_TCP_PORT` | `4444` | TCP port the client connects to |
|
|
111
|
+
| `NANOFORGE_CLIENT_SERVER_UDP_PORT` | `4445` | UDP port the client connects to |
|
|
112
|
+
| `NANOFORGE_SERVER_LISTENING_TCP_PORT` | `4444` | TCP port the server listens on |
|
|
113
|
+
| `NANOFORGE_SERVER_LISTENING_UDP_PORT` | `4445` | UDP port the server listens on |
|
|
114
|
+
|
|
115
|
+
<% } %>---
|
|
116
|
+
|
|
117
|
+
## Build
|
|
118
|
+
|
|
119
|
+
Compile the game for production:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
<%= packageManager %> run build
|
|
123
|
+
# or
|
|
124
|
+
nf build
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Output is written to the `.nanoforge/` directory.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Run
|
|
132
|
+
|
|
133
|
+
Start the game server and open it in a browser:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
<%= packageManager %> run start
|
|
137
|
+
# or
|
|
138
|
+
nf start
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
<% if (lint) { %>---
|
|
142
|
+
|
|
143
|
+
## Code quality
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# Check formatting and linting
|
|
147
|
+
<%= packageManager %> run lint
|
|
148
|
+
|
|
149
|
+
# Auto-fix formatting and linting
|
|
150
|
+
<%= packageManager %> run format
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
<% } %>---
|
|
154
|
+
|
|
155
|
+
## CLI reference
|
|
156
|
+
|
|
157
|
+
| Command | Description |
|
|
158
|
+
|--------------------------------|-------------------------------------------|
|
|
159
|
+
| `nf dev` | Start in development mode with hot reload |
|
|
160
|
+
| `nf build` | Build for production |
|
|
161
|
+
| `nf start` | Run the built game |
|
|
162
|
+
| `nf generate component <name>` | Scaffold a new component |
|
|
163
|
+
| `nf generate system <name>` | Scaffold a new system |<% if (editor) { %>
|
|
164
|
+
| `nf editor` | Open the visual editor |<% } %>
|
|
165
|
+
|
|
166
|
+
Full CLI documentation: <https://docs.nanoforge.eu>
|