@nanoforge-dev/schematics 2.2.1 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +474 -0
- package/README.md +12 -15
- package/dist/collection.json +8 -23
- package/dist/index.cjs +21 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -7
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +19 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -4
- package/dist/index.js.map +1 -1
- package/dist/libs/component/component.factory.d.ts +1 -3
- package/dist/libs/component/component.factory.d.ts.map +1 -1
- package/dist/libs/component/component.factory.js +2 -1
- package/dist/libs/component/component.factory.js.map +1 -1
- package/dist/libs/project/files/js/.dockerignore +5 -0
- package/dist/libs/project/files/js/Dockerfile +36 -0
- package/dist/libs/project/files/js/README.md +53 -0
- package/dist/libs/project/files/js/assets/__dot__gitkeep +0 -0
- package/dist/libs/project/files/js/jsconfig.json +36 -0
- package/dist/libs/project/files/js/nanoforge.config.js +10 -0
- package/dist/libs/project/files/js/package.json.template +29 -0
- package/dist/libs/project/files/js/pnpm-workspace.yaml.template +3 -0
- package/dist/libs/project/files/js/src/components/drawable-circle-2d.component.js +404 -0
- package/dist/libs/project/files/js/src/components/position-2d.component.js +42 -0
- package/dist/libs/project/files/js/src/main.js +43 -0
- package/dist/libs/project/files/js/src/systems/draw-2d.system.js +33 -0
- package/dist/libs/project/files/js/src/systems/move-2d.system.js +34 -0
- package/dist/libs/project/files/js/src/systems/position-sync.system.js +35 -0
- package/dist/libs/project/files/ts/.dockerignore +5 -0
- package/dist/libs/project/files/ts/Dockerfile +36 -0
- package/dist/libs/project/files/ts/README.md +53 -0
- package/dist/libs/project/files/ts/assets/__dot__gitkeep +0 -0
- package/dist/libs/project/files/ts/nanoforge.config.ts +5 -0
- package/dist/libs/project/files/ts/package.json.template +29 -0
- package/dist/libs/project/files/ts/pnpm-workspace.yaml.template +3 -0
- package/dist/libs/project/files/ts/src/components/drawable-circle-2d.component.ts +367 -0
- package/dist/libs/project/files/ts/src/components/position-2d.component.ts +35 -0
- package/dist/libs/project/files/ts/src/main.ts +40 -0
- package/dist/libs/project/files/ts/src/systems/draw-2d.system.ts +25 -0
- package/dist/libs/project/files/ts/src/systems/move-2d.system.ts +26 -0
- package/dist/libs/project/files/ts/src/systems/position-sync.system.ts +27 -0
- package/dist/libs/project/files/ts/tsconfig.json +42 -0
- package/dist/libs/project/project.factory.d.ts +64 -0
- package/dist/libs/project/project.factory.d.ts.map +1 -0
- package/dist/libs/project/project.factory.js +127 -0
- package/dist/libs/project/project.factory.js.map +1 -0
- package/dist/libs/project/schema.json +83 -0
- package/dist/libs/system/system.factory.d.ts +1 -3
- package/dist/libs/system/system.factory.d.ts.map +1 -1
- package/dist/libs/system/system.factory.js +2 -1
- package/dist/libs/system/system.factory.js.map +1 -1
- package/dist/libs/workspace/files/js/.dockerignore +5 -0
- package/dist/libs/workspace/files/js/Dockerfile +36 -0
- package/dist/libs/workspace/files/js/README.md +51 -0
- package/dist/libs/workspace/files/js/__dot__gitignore +137 -0
- package/dist/libs/{application → workspace}/files/js/jsconfig.json +1 -2
- package/dist/libs/workspace/files/js/nanoforge.config.js +6 -0
- package/dist/libs/workspace/files/js/package.json.template +19 -0
- package/dist/libs/workspace/files/js/pnpm-workspace.yaml.template +6 -0
- package/dist/libs/workspace/files/ts/.dockerignore +5 -0
- package/dist/libs/workspace/files/ts/Dockerfile +36 -0
- package/dist/libs/workspace/files/ts/README.md +51 -0
- package/dist/libs/workspace/files/ts/__dot__gitignore +134 -0
- package/dist/libs/workspace/files/ts/nanoforge.config.ts +6 -0
- package/dist/libs/workspace/files/ts/package.json.template +20 -0
- package/dist/libs/workspace/files/ts/pnpm-workspace.yaml.template +6 -0
- package/dist/libs/{application → workspace}/files/ts/tsconfig.json +1 -2
- package/dist/libs/workspace/schema.json +45 -0
- package/dist/libs/workspace/workspace.factory.d.ts +42 -0
- package/dist/libs/workspace/workspace.factory.d.ts.map +1 -0
- package/dist/libs/workspace/workspace.factory.js +116 -0
- package/dist/libs/workspace/workspace.factory.js.map +1 -0
- package/package.json +23 -21
- package/dist/libs/application/application.factory.d.ts +0 -59
- package/dist/libs/application/application.factory.d.ts.map +0 -1
- package/dist/libs/application/application.factory.js +0 -57
- package/dist/libs/application/application.factory.js.map +0 -1
- package/dist/libs/application/files/js/.prettierignore +0 -8
- package/dist/libs/application/files/js/README.md +0 -166
- package/dist/libs/application/files/js/eslint.config.js +0 -11
- package/dist/libs/application/files/js/package.json.template +0 -48
- package/dist/libs/application/files/js/pnpm-workspace.yaml.template +0 -3
- package/dist/libs/application/files/js/prettier.config.js +0 -6
- package/dist/libs/application/files/ts/.prettierignore +0 -8
- package/dist/libs/application/files/ts/README.md +0 -166
- package/dist/libs/application/files/ts/eslint.config.js +0 -15
- package/dist/libs/application/files/ts/package.json.template +0 -52
- package/dist/libs/application/files/ts/pnpm-workspace.yaml.template +0 -3
- package/dist/libs/application/files/ts/prettier.config.js +0 -6
- package/dist/libs/application/schema.json +0 -70
- package/dist/libs/configuration/configuration.factory.d.ts +0 -31
- package/dist/libs/configuration/configuration.factory.d.ts.map +0 -1
- package/dist/libs/configuration/configuration.factory.js +0 -97
- package/dist/libs/configuration/configuration.factory.js.map +0 -1
- package/dist/libs/configuration/files/nanoforge.config.json +0 -1
- package/dist/libs/configuration/schema.json +0 -34
- package/dist/libs/docker/docker.factory.d.ts +0 -19
- package/dist/libs/docker/docker.factory.d.ts.map +0 -1
- package/dist/libs/docker/docker.factory.js +0 -20
- package/dist/libs/docker/docker.factory.js.map +0 -1
- package/dist/libs/docker/files/.dockerignore +0 -1
- package/dist/libs/docker/files/Dockerfile +0 -25
- package/dist/libs/docker/schema.json +0 -19
- package/dist/libs/part-base/files/js/__nanoforgeFolder__/client.save.json +0 -77
- package/dist/libs/part-base/files/js/__nanoforgeFolder__/server.save.json +0 -49
- package/dist/libs/part-base/files/js/__part__/components/example.component.js +0 -72
- package/dist/libs/part-base/files/js/__part__/init/after-init.js +0 -12
- package/dist/libs/part-base/files/js/__part__/init/after-registry-init.js +0 -14
- package/dist/libs/part-base/files/js/__part__/init/after-run.js +0 -12
- package/dist/libs/part-base/files/js/__part__/init/before-init.js +0 -13
- package/dist/libs/part-base/files/js/__part__/init/before-registry-init.js +0 -14
- package/dist/libs/part-base/files/js/__part__/init/before-run.js +0 -12
- package/dist/libs/part-base/files/js/__part__/systems/example.system.js +0 -44
- package/dist/libs/part-base/files/ts/__nanoforgeFolder__/client.save.json +0 -77
- package/dist/libs/part-base/files/ts/__nanoforgeFolder__/server.save.json +0 -49
- package/dist/libs/part-base/files/ts/__part__/components/example.component.ts +0 -55
- package/dist/libs/part-base/files/ts/__part__/init/after-init.ts +0 -5
- package/dist/libs/part-base/files/ts/__part__/init/after-registry-init.ts +0 -6
- package/dist/libs/part-base/files/ts/__part__/init/after-run.ts +0 -5
- package/dist/libs/part-base/files/ts/__part__/init/before-init.ts +0 -5
- package/dist/libs/part-base/files/ts/__part__/init/before-registry-init.ts +0 -6
- package/dist/libs/part-base/files/ts/__part__/init/before-run.ts +0 -5
- package/dist/libs/part-base/files/ts/__part__/systems/example.system.ts +0 -31
- package/dist/libs/part-base/part-base.factory.d.ts +0 -31
- package/dist/libs/part-base/part-base.factory.d.ts.map +0 -1
- package/dist/libs/part-base/part-base.factory.js +0 -33
- package/dist/libs/part-base/part-base.factory.js.map +0 -1
- package/dist/libs/part-base/schema.json +0 -35
- package/dist/libs/part-main/part-main.factory.d.ts +0 -39
- package/dist/libs/part-main/part-main.factory.d.ts.map +0 -1
- package/dist/libs/part-main/part-main.factory.js +0 -252
- package/dist/libs/part-main/part-main.factory.js.map +0 -1
- package/dist/libs/part-main/schema.json +0 -43
- /package/dist/libs/{application → project}/files/js/__dot__gitignore +0 -0
- /package/dist/libs/{application → project}/files/ts/__dot__gitignore +0 -0
- /package/dist/libs/{application → workspace}/files/js/__dot__env +0 -0
- /package/dist/libs/{application → workspace}/files/ts/__dot__env +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
### VisualStudioCode template
|
|
2
|
+
.vscode/*
|
|
3
|
+
!.vscode/settings.json
|
|
4
|
+
!.vscode/tasks.json
|
|
5
|
+
!.vscode/launch.json
|
|
6
|
+
!.vscode/extensions.json
|
|
7
|
+
!.vscode/*.code-snippets
|
|
8
|
+
|
|
9
|
+
# Local History for Visual Studio Code
|
|
10
|
+
.history/
|
|
11
|
+
|
|
12
|
+
# Built Visual Studio Code Extensions
|
|
13
|
+
*.vsix
|
|
14
|
+
|
|
15
|
+
### JetBrains template
|
|
16
|
+
|
|
17
|
+
# User-specific stuff
|
|
18
|
+
.idea/**/workspace.xml
|
|
19
|
+
.idea/**/tasks.xml
|
|
20
|
+
.idea/**/usage.statistics.xml
|
|
21
|
+
.idea/**/dictionaries
|
|
22
|
+
.idea/**/shelf
|
|
23
|
+
|
|
24
|
+
# Generated files
|
|
25
|
+
.idea/**/contentModel.xml
|
|
26
|
+
|
|
27
|
+
# Sensitive or high-churn files
|
|
28
|
+
.idea/**/dataSources/
|
|
29
|
+
.idea/**/dataSources.ids
|
|
30
|
+
.idea/**/dataSources.local.xml
|
|
31
|
+
.idea/**/sqlDataSources.xml
|
|
32
|
+
.idea/**/dynamic.xml
|
|
33
|
+
.idea/**/uiDesigner.xml
|
|
34
|
+
.idea/**/dbnavigator.xml
|
|
35
|
+
|
|
36
|
+
# File-based project format
|
|
37
|
+
*.iws
|
|
38
|
+
|
|
39
|
+
# Editor-based Rest Client
|
|
40
|
+
.idea/httpRequests
|
|
41
|
+
|
|
42
|
+
### Node template
|
|
43
|
+
# Logs
|
|
44
|
+
logs
|
|
45
|
+
*.log
|
|
46
|
+
npm-debug.log*
|
|
47
|
+
yarn-debug.log*
|
|
48
|
+
yarn-error.log*
|
|
49
|
+
lerna-debug.log*
|
|
50
|
+
.pnpm-debug.log*
|
|
51
|
+
|
|
52
|
+
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
53
|
+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
54
|
+
|
|
55
|
+
# Runtime data
|
|
56
|
+
pids
|
|
57
|
+
*.pid
|
|
58
|
+
*.seed
|
|
59
|
+
*.pid.lock
|
|
60
|
+
|
|
61
|
+
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
62
|
+
lib-cov
|
|
63
|
+
|
|
64
|
+
# Coverage directory used by tools like istanbul
|
|
65
|
+
coverage
|
|
66
|
+
*.lcov
|
|
67
|
+
|
|
68
|
+
# nyc test coverage
|
|
69
|
+
.nyc_output
|
|
70
|
+
|
|
71
|
+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
72
|
+
.grunt
|
|
73
|
+
|
|
74
|
+
# Bower dependency directory (https://bower.io/)
|
|
75
|
+
bower_components
|
|
76
|
+
|
|
77
|
+
# node-waf configuration
|
|
78
|
+
.lock-wscript
|
|
79
|
+
|
|
80
|
+
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
81
|
+
build/Release
|
|
82
|
+
|
|
83
|
+
# Dependency directories
|
|
84
|
+
node_modules/
|
|
85
|
+
jspm_packages/
|
|
86
|
+
|
|
87
|
+
# Snowpack dependency directory (https://snowpack.dev/)
|
|
88
|
+
web_modules/
|
|
89
|
+
|
|
90
|
+
# TypeScript cache
|
|
91
|
+
*.tsbuildinfo
|
|
92
|
+
|
|
93
|
+
# Optional npm cache directory
|
|
94
|
+
.npm
|
|
95
|
+
|
|
96
|
+
# Optional eslint cache
|
|
97
|
+
.eslintcache
|
|
98
|
+
|
|
99
|
+
# Optional stylelint cache
|
|
100
|
+
.stylelintcache
|
|
101
|
+
|
|
102
|
+
# Microbundle cache
|
|
103
|
+
.rpt2_cache/
|
|
104
|
+
.rts2_cache_cjs/
|
|
105
|
+
.rts2_cache_es/
|
|
106
|
+
.rts2_cache_umd/
|
|
107
|
+
|
|
108
|
+
# Optional REPL history
|
|
109
|
+
.node_repl_history
|
|
110
|
+
|
|
111
|
+
# Output of 'npm pack'
|
|
112
|
+
*.tgz
|
|
113
|
+
|
|
114
|
+
# Yarn Integrity file
|
|
115
|
+
.yarn-integrity
|
|
116
|
+
|
|
117
|
+
# dotenv environment variable files
|
|
118
|
+
.env
|
|
119
|
+
.env.development.local
|
|
120
|
+
.env.test.local
|
|
121
|
+
.env.production.local
|
|
122
|
+
.env.local
|
|
123
|
+
|
|
124
|
+
# yarn v2
|
|
125
|
+
.yarn/cache
|
|
126
|
+
.yarn/unplugged
|
|
127
|
+
.yarn/build-state.yml
|
|
128
|
+
.yarn/install-state.gz
|
|
129
|
+
.pnp.*
|
|
130
|
+
|
|
131
|
+
### NanoForge template
|
|
132
|
+
# Build/compilation output
|
|
133
|
+
.nanoforge/
|
|
134
|
+
dist/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
+
"name": "<%= name %>",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"dev": "nf dev -r",
|
|
6
|
+
"build": "nf build -r",
|
|
7
|
+
"start": "nf start -r"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"@nanoforge-dev/cli": "<%= cliVersion %>",
|
|
11
|
+
"@nanoforge-dev/config": "<%= engineVersion %>",
|
|
12
|
+
"typescript": "<%= typescriptVersion %>"
|
|
13
|
+
},<% if (packageManager !== "pnpm") { %>
|
|
14
|
+
"workspaces": ["apps/*"],<% } %><% if (packageManager === "npm" && allowBuilds.length > 0) { %>
|
|
15
|
+
"allowScripts": {<% allowBuilds.forEach(function (pkg, i) { %>
|
|
16
|
+
"<%= pkg %>": true<% if (i < allowBuilds.length - 1) { %>,<% } %><% }); %>
|
|
17
|
+
},<% } %><% if (packageManager === "bun" && allowBuilds.length > 0) { %>
|
|
18
|
+
"trustedDependencies": [<% allowBuilds.forEach(function (pkg, i) { %>"<%= pkg %>"<% if (i < allowBuilds.length - 1) { %>, <% } %><% }); %>],<% } %>
|
|
19
|
+
"private": true
|
|
20
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "SchematicsNanoForgeWorkspace",
|
|
4
|
+
"title": "NanoForge Workspace Options Schema",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"name": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The name of the workspace",
|
|
10
|
+
"default": "nanoforge-app"
|
|
11
|
+
},
|
|
12
|
+
"directory": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "NanoForge workspace destination directory (defaults to the workspace name when omitted)"
|
|
15
|
+
},
|
|
16
|
+
"language": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"enum": ["ts", "js"],
|
|
19
|
+
"description": "NanoForge workspace language",
|
|
20
|
+
"default": "ts"
|
|
21
|
+
},
|
|
22
|
+
"strict": {
|
|
23
|
+
"type": "boolean",
|
|
24
|
+
"description": "With strict mode (TypeScript or JavaScript but only on compatible editor)",
|
|
25
|
+
"default": true
|
|
26
|
+
},
|
|
27
|
+
"packageManager": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"enum": ["npm", "yarn", "pnpm", "bun"],
|
|
30
|
+
"description": "NanoForge workspace package manager",
|
|
31
|
+
"default": "npm"
|
|
32
|
+
},
|
|
33
|
+
"allowBuilds": {
|
|
34
|
+
"type": "array",
|
|
35
|
+
"items": { "type": "string" },
|
|
36
|
+
"description": "Package names allowed to run install/build scripts, in addition to `bun` which is always allowed (@nanoforge-dev/cli depends on it and it has its own install script). Written to pnpm-workspace.yaml (pnpm), package.json's allowScripts (npm) or trustedDependencies (bun). Ignored for yarn.",
|
|
37
|
+
"default": []
|
|
38
|
+
},
|
|
39
|
+
"docker": {
|
|
40
|
+
"type": "boolean",
|
|
41
|
+
"description": "Generate a Dockerfile building every app in the workspace into one image",
|
|
42
|
+
"default": false
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Rule } from "@angular-devkit/schematics";
|
|
2
|
+
//#region src/libs/workspace/workspace.schema.d.ts
|
|
3
|
+
interface WorkspaceSchema {
|
|
4
|
+
/**
|
|
5
|
+
* NanoForge workspace name
|
|
6
|
+
*/
|
|
7
|
+
name: string;
|
|
8
|
+
/**
|
|
9
|
+
* NanoForge workspace destination directory
|
|
10
|
+
*/
|
|
11
|
+
directory: string;
|
|
12
|
+
/**
|
|
13
|
+
* NanoForge workspace language
|
|
14
|
+
*/
|
|
15
|
+
language: "js" | "ts";
|
|
16
|
+
/**
|
|
17
|
+
* With strict mode (TypeScript or JavaScript but only on compatible editor)
|
|
18
|
+
*/
|
|
19
|
+
strict: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The used package manager
|
|
22
|
+
*/
|
|
23
|
+
packageManager: "npm" | "yarn" | "pnpm" | "bun";
|
|
24
|
+
/**
|
|
25
|
+
* Package names allowed to run install/build scripts. Written to
|
|
26
|
+
* pnpm-workspace.yaml's `allowBuilds` map (pnpm), package.json's
|
|
27
|
+
* `allowScripts` map (npm) or `trustedDependencies` array (bun). Ignored
|
|
28
|
+
* for yarn. `bun` is always included in addition to this list since
|
|
29
|
+
* @nanoforge-dev/cli transitively depends on it and it has its own
|
|
30
|
+
* install script.
|
|
31
|
+
*/
|
|
32
|
+
allowBuilds: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Generate a Dockerfile building every app in the workspace into one image
|
|
35
|
+
*/
|
|
36
|
+
docker: boolean;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/libs/workspace/workspace.factory.d.ts
|
|
40
|
+
export declare const main: (schema: WorkspaceSchema) => Rule;
|
|
41
|
+
//#endregion
|
|
42
|
+
//# sourceMappingURL=workspace.factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.factory.d.ts","names":[],"sources":["../../../src/libs/workspace/workspace.schema.d.ts","../../../src/libs/workspace/workspace.factory.ts"],"mappings":";;UAAiB;;;;EAIf;;;;EAKA;;;;EAKA;;;;EAKA;;;;EAKA;;;;;;;;;EAUA;;;;EAKA;;;;qBCqCW,OAAQ,QAAQ,oBAAkB"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { join, normalize, strings } from "@angular-devkit/core";
|
|
2
|
+
import { apply, filter, mergeWith, move, renameTemplateFiles, template, url } from "@angular-devkit/schematics";
|
|
3
|
+
/** Fallback used when the registry lookup for `@nanoforge-dev/cli` fails. */
|
|
4
|
+
const DEFAULT_CLI_DEPENDENCY_VERSION = "latest";
|
|
5
|
+
/**
|
|
6
|
+
* Fallback used when the registry lookup for `typescript` fails. A specific
|
|
7
|
+
* version, not a range — non-nanoforge packages are pinned exactly.
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_TYPESCRIPT_VERSION = "6.0.3";
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/utils/registry.ts
|
|
12
|
+
const REGISTRY_URL = "https://registry.npmjs.org";
|
|
13
|
+
const DEFAULT_TIMEOUT_MS = 3e3;
|
|
14
|
+
const RELEASE_VERSION_PATTERN = /^\d+\.\d+\.\d+$/;
|
|
15
|
+
const compareVersions = (a, b) => {
|
|
16
|
+
const partsA = a.split(".").map(Number);
|
|
17
|
+
const partsB = b.split(".").map(Number);
|
|
18
|
+
for (let i = 0; i < 3; i++) {
|
|
19
|
+
const diff = (partsA[i] ?? 0) - (partsB[i] ?? 0);
|
|
20
|
+
if (diff !== 0) return diff;
|
|
21
|
+
}
|
|
22
|
+
return 0;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Resolves the newest published version of an npm package that is at least
|
|
26
|
+
* `minAgeHours` old, so freshly (and potentially maliciously) published
|
|
27
|
+
* versions aren't picked up immediately. Falls back to `fallback` on any
|
|
28
|
+
* network error, timeout, missing package, or when no version satisfies the
|
|
29
|
+
* constraints, so callers never have to handle a rejected promise.
|
|
30
|
+
*/
|
|
31
|
+
const fetchTrustedVersion = async (packageName, fallback, options = {}) => {
|
|
32
|
+
const { minAgeHours = 48, major, timeoutMs = DEFAULT_TIMEOUT_MS } = options;
|
|
33
|
+
const controller = new AbortController();
|
|
34
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
35
|
+
try {
|
|
36
|
+
const response = await fetch(`${REGISTRY_URL}/${encodeURIComponent(packageName)}`, { signal: controller.signal });
|
|
37
|
+
if (!response.ok) return fallback;
|
|
38
|
+
const time = (await response.json()).time;
|
|
39
|
+
if (!time) return fallback;
|
|
40
|
+
const cutoff = Date.now() - minAgeHours * 60 * 60 * 1e3;
|
|
41
|
+
const eligible = Object.entries(time).filter(([version]) => RELEASE_VERSION_PATTERN.test(version)).filter(([version]) => major === void 0 || Number(version.split(".")[0]) === major).filter(([, publishedAt]) => new Date(publishedAt).getTime() <= cutoff).map(([version]) => version).sort(compareVersions);
|
|
42
|
+
return eligible.at(-1) ? `^${eligible.at(-1)}` : fallback;
|
|
43
|
+
} catch {
|
|
44
|
+
return fallback;
|
|
45
|
+
} finally {
|
|
46
|
+
clearTimeout(timeout);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Resolves several packages' trusted versions in parallel. Keys of `specs`
|
|
51
|
+
* are the package name to query the registry for; values are the fallback
|
|
52
|
+
* to use if that lookup fails. Returns a map from the *same* keys to the
|
|
53
|
+
* resolved (or fallback) version — typed so callers don't get `| undefined`
|
|
54
|
+
* back for a key they just passed in.
|
|
55
|
+
*/
|
|
56
|
+
const fetchTrustedVersions = async (specs) => {
|
|
57
|
+
const entries = await Promise.all(Object.entries(specs).map(async ([packageName, { fallback, major }]) => {
|
|
58
|
+
return [packageName, await fetchTrustedVersion(packageName, fallback, { major })];
|
|
59
|
+
}));
|
|
60
|
+
return Object.fromEntries(entries);
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/libs/workspace/workspace.factory.ts
|
|
64
|
+
/**
|
|
65
|
+
* bun ships as a postinstall-driven binary download (its own package.json
|
|
66
|
+
* declares `"postinstall": "node install.js"`), and @nanoforge-dev/cli
|
|
67
|
+
* depends on it unconditionally, so every generated workspace needs it
|
|
68
|
+
* approved to run its build script regardless of what the caller passes.
|
|
69
|
+
*/
|
|
70
|
+
const ALWAYS_ALLOWED_BUILDS = ["bun"];
|
|
71
|
+
const transform = async (schema) => {
|
|
72
|
+
const packageManager = schema.packageManager ?? "npm";
|
|
73
|
+
const versions = await fetchTrustedVersions({
|
|
74
|
+
"@nanoforge-dev/cli": { fallback: DEFAULT_CLI_DEPENDENCY_VERSION },
|
|
75
|
+
"@nanoforge-dev/core": { fallback: "^2" },
|
|
76
|
+
typescript: {
|
|
77
|
+
fallback: DEFAULT_TYPESCRIPT_VERSION,
|
|
78
|
+
major: 6
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
name: schema.name,
|
|
83
|
+
engineVersion: versions["@nanoforge-dev/core"],
|
|
84
|
+
cliVersion: versions["@nanoforge-dev/cli"],
|
|
85
|
+
typescriptVersion: versions.typescript,
|
|
86
|
+
language: schema.language,
|
|
87
|
+
strict: schema.strict,
|
|
88
|
+
packageManager,
|
|
89
|
+
allowBuilds: Array.from(/* @__PURE__ */ new Set([...ALWAYS_ALLOWED_BUILDS, ...schema.allowBuilds ?? []])),
|
|
90
|
+
docker: schema.docker ?? false
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
const generate = (options, path) => {
|
|
94
|
+
return apply(url(join("./files", options.language)), [
|
|
95
|
+
template({
|
|
96
|
+
dot: ".",
|
|
97
|
+
...strings,
|
|
98
|
+
...options
|
|
99
|
+
}),
|
|
100
|
+
filter((path) => options.packageManager === "pnpm" || !(path.split("/").at(-1) ?? "").startsWith("pnpm-workspace.yaml")),
|
|
101
|
+
filter((path) => options.docker || !["Dockerfile", ".dockerignore"].includes(path.split("/").at(-1) ?? "")),
|
|
102
|
+
renameTemplateFiles(),
|
|
103
|
+
move(normalize(path))
|
|
104
|
+
]);
|
|
105
|
+
};
|
|
106
|
+
const main = (schema) => {
|
|
107
|
+
return async () => {
|
|
108
|
+
const options = await transform(schema);
|
|
109
|
+
const path = schema.directory ?? options.name;
|
|
110
|
+
return mergeWith(generate(options, path));
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
//#endregion
|
|
114
|
+
export { main };
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=workspace.factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace.factory.js","names":[],"sources":["../../../src/defaults.ts","../../../src/utils/registry.ts","../../../src/libs/workspace/workspace.factory.ts"],"sourcesContent":["export const DEFAULT_APP_NAME = \"nanoforge-app\";\nexport const DEFAULT_LANGUAGE = \"ts\";\nexport const DEFAULT_PACKAGE_MANAGER = \"npm\";\nexport const DEFAULT_NANOFORGE_DEPENDENCY_VERSION = \"^2\";\nexport const DEFAULT_ENGINE_VERSION = \"^2\";\n\n/** Fallback used when the registry lookup for `@nanoforge-dev/cli` fails. */\nexport const DEFAULT_CLI_DEPENDENCY_VERSION = \"latest\";\n\n/**\n * Fallback used when the registry lookup for `typescript` fails. A specific\n * version, not a range — non-nanoforge packages are pinned exactly.\n */\nexport const DEFAULT_TYPESCRIPT_VERSION = \"6.0.3\";\n\n/**\n * Mirrors pnpm's own `minimumReleaseAge` supply-chain protection: when\n * resolving a pinned dependency version at generation time, only consider\n * versions published at least this long ago, so a freshly (and potentially\n * maliciously) published release isn't picked up immediately.\n */\nexport const MIN_RELEASE_AGE_HOURS = 48;\n","import { MIN_RELEASE_AGE_HOURS } from \"~/defaults\";\n\nconst REGISTRY_URL = \"https://registry.npmjs.org\";\nconst DEFAULT_TIMEOUT_MS = 3000;\n\nconst RELEASE_VERSION_PATTERN = /^\\d+\\.\\d+\\.\\d+$/;\n\nconst compareVersions = (a: string, b: string): number => {\n const partsA = a.split(\".\").map(Number);\n const partsB = b.split(\".\").map(Number);\n for (let i = 0; i < 3; i++) {\n const diff = (partsA[i] ?? 0) - (partsB[i] ?? 0);\n if (diff !== 0) {\n return diff;\n }\n }\n return 0;\n};\n\nexport interface FetchTrustedVersionOptions {\n /**\n * Only consider versions published at least this many hours ago, mirroring\n * pnpm's `minimumReleaseAge` supply-chain protection for a freshly\n * published (and potentially compromised) release.\n * @default MIN_RELEASE_AGE_HOURS\n */\n minAgeHours?: number;\n\n /**\n * Restrict candidates to this major version (e.g. `6` only considers\n * `6.x.x`). Useful to avoid silently jumping a generated project onto a\n * new major release.\n */\n major?: number;\n\n /** Network timeout in milliseconds. @default 3000 */\n timeoutMs?: number;\n}\n\n/**\n * Resolves the newest published version of an npm package that is at least\n * `minAgeHours` old, so freshly (and potentially maliciously) published\n * versions aren't picked up immediately. Falls back to `fallback` on any\n * network error, timeout, missing package, or when no version satisfies the\n * constraints, so callers never have to handle a rejected promise.\n */\nexport const fetchTrustedVersion = async (\n packageName: string,\n fallback: string,\n options: FetchTrustedVersionOptions = {},\n): Promise<string> => {\n const { minAgeHours = MIN_RELEASE_AGE_HOURS, major, timeoutMs = DEFAULT_TIMEOUT_MS } = options;\n\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), timeoutMs);\n\n try {\n const response = await fetch(`${REGISTRY_URL}/${encodeURIComponent(packageName)}`, {\n signal: controller.signal,\n });\n if (!response.ok) {\n return fallback;\n }\n\n const data = (await response.json()) as { time?: Record<string, string> };\n const time = data.time;\n if (!time) {\n return fallback;\n }\n\n const cutoff = Date.now() - minAgeHours * 60 * 60 * 1000;\n const eligible = Object.entries(time)\n .filter(([version]) => RELEASE_VERSION_PATTERN.test(version))\n .filter(([version]) => major === undefined || Number(version.split(\".\")[0]) === major)\n .filter(([, publishedAt]) => new Date(publishedAt).getTime() <= cutoff)\n .map(([version]) => version)\n .sort(compareVersions);\n\n return eligible.at(-1) ? `^${eligible.at(-1)}` : fallback;\n } catch {\n return fallback;\n } finally {\n clearTimeout(timeout);\n }\n};\n\n/**\n * Resolves several packages' trusted versions in parallel. Keys of `specs`\n * are the package name to query the registry for; values are the fallback\n * to use if that lookup fails. Returns a map from the *same* keys to the\n * resolved (or fallback) version — typed so callers don't get `| undefined`\n * back for a key they just passed in.\n */\nexport const fetchTrustedVersions = async <\n T extends Record<string, { fallback: string; major?: number }>,\n>(\n specs: T,\n): Promise<{ [K in keyof T]: string }> => {\n const entries = await Promise.all(\n Object.entries(specs).map(async ([packageName, { fallback, major }]) => {\n const version = await fetchTrustedVersion(packageName, fallback, { major });\n return [packageName, version] as const;\n }),\n );\n return Object.fromEntries(entries) as { [K in keyof T]: string };\n};\n","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 renameTemplateFiles,\n template,\n url,\n} from \"@angular-devkit/schematics\";\n\nimport { fetchTrustedVersions } from \"@utils/registry\";\n\nimport {\n DEFAULT_CLI_DEPENDENCY_VERSION,\n DEFAULT_ENGINE_VERSION,\n DEFAULT_PACKAGE_MANAGER,\n DEFAULT_TYPESCRIPT_VERSION,\n} from \"~/defaults\";\n\nimport { type WorkspaceOptions } from \"./workspace.options\";\nimport { type WorkspaceSchema } from \"./workspace.schema\";\n\n/**\n * bun ships as a postinstall-driven binary download (its own package.json\n * declares `\"postinstall\": \"node install.js\"`), and @nanoforge-dev/cli\n * depends on it unconditionally, so every generated workspace needs it\n * approved to run its build script regardless of what the caller passes.\n */\nconst ALWAYS_ALLOWED_BUILDS = [\"bun\"];\n\nconst transform = async (schema: WorkspaceSchema): Promise<WorkspaceOptions> => {\n const packageManager = schema.packageManager ?? DEFAULT_PACKAGE_MANAGER;\n\n const versions = await fetchTrustedVersions({\n \"@nanoforge-dev/cli\": { fallback: DEFAULT_CLI_DEPENDENCY_VERSION },\n \"@nanoforge-dev/core\": { fallback: DEFAULT_ENGINE_VERSION },\n typescript: { fallback: DEFAULT_TYPESCRIPT_VERSION, major: 6 },\n });\n\n return {\n name: schema.name,\n engineVersion: versions[\"@nanoforge-dev/core\"],\n cliVersion: versions[\"@nanoforge-dev/cli\"],\n typescriptVersion: versions.typescript,\n language: schema.language,\n strict: schema.strict,\n packageManager,\n allowBuilds: Array.from(new Set([...ALWAYS_ALLOWED_BUILDS, ...(schema.allowBuilds ?? [])])),\n docker: schema.docker ?? false,\n };\n};\n\nconst generate = (options: WorkspaceOptions, path: string): Source => {\n return apply(url(join(\"./files\" as Path, options.language)), [\n template({\n dot: \".\",\n ...strings,\n ...options,\n }),\n filter(\n (path) =>\n options.packageManager === \"pnpm\" ||\n !(path.split(\"/\").at(-1) ?? \"\").startsWith(\"pnpm-workspace.yaml\"),\n ),\n filter(\n (path) =>\n options.docker || ![\"Dockerfile\", \".dockerignore\"].includes(path.split(\"/\").at(-1) ?? \"\"),\n ),\n renameTemplateFiles(),\n move(normalize(path)),\n ]);\n};\n\nexport const main = (schema: WorkspaceSchema): Rule => {\n return async () => {\n const options = await transform(schema);\n const path = schema.directory ?? options.name;\n\n return mergeWith(generate(options, path));\n };\n};\n"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@nanoforge-dev/schematics",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.1",
|
|
5
5
|
"description": "NanoForge Schematics",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"nanoforge",
|
|
8
8
|
"game",
|
|
9
9
|
"schematics"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://github.com/NanoForge-dev/
|
|
12
|
-
"bugs": "https://github.com/NanoForge-dev/
|
|
11
|
+
"homepage": "https://github.com/NanoForge-dev/CLI#readme",
|
|
12
|
+
"bugs": "https://github.com/NanoForge-dev/CLI/issues",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"contributors": [
|
|
15
|
-
"
|
|
16
|
-
"Exelo <exelo.corp@gmail.com>",
|
|
15
|
+
"Exelo <contact@exelo.dev>",
|
|
17
16
|
"Fexkoser <martin.fillon@epitech.eu>",
|
|
18
|
-
"
|
|
17
|
+
"Harper <timothe.jacquot@epitech.eu>",
|
|
18
|
+
"Josephine <josephine.chicouras@epitech.eu>",
|
|
19
|
+
"Leo <leo.outmizguine@epitech.eu>"
|
|
19
20
|
],
|
|
20
21
|
"files": [
|
|
21
22
|
"dist"
|
|
@@ -43,36 +44,37 @@
|
|
|
43
44
|
},
|
|
44
45
|
"repository": {
|
|
45
46
|
"type": "git",
|
|
46
|
-
"url": "git+https://github.com/NanoForge-dev/
|
|
47
|
+
"url": "git+https://github.com/NanoForge-dev/CLI.git",
|
|
48
|
+
"directory": "libs/schematics"
|
|
47
49
|
},
|
|
48
|
-
"funding": "https://github.com/NanoForge-dev/
|
|
50
|
+
"funding": "https://github.com/NanoForge-dev/CLI?sponsor",
|
|
49
51
|
"dependencies": {
|
|
50
52
|
"@angular-devkit/core": "^22.0.4",
|
|
51
|
-
"@angular-devkit/schematics": "^22.
|
|
53
|
+
"@angular-devkit/schematics": "^22.1.8",
|
|
52
54
|
"rxjs": "^7.8.2"
|
|
53
55
|
},
|
|
54
56
|
"devDependencies": {
|
|
55
|
-
"@angular-devkit/schematics-cli": "^22.
|
|
56
|
-
"@commitlint/cli": "^21.
|
|
57
|
-
"@commitlint/config-conventional": "^21.
|
|
57
|
+
"@angular-devkit/schematics-cli": "^22.1.8",
|
|
58
|
+
"@commitlint/cli": "^21.2.3",
|
|
59
|
+
"@commitlint/config-conventional": "^21.2.3",
|
|
58
60
|
"@favware/cliff-jumper": "^6.1.0",
|
|
59
61
|
"@nanoforge-dev/actions": "^2.1.5",
|
|
60
62
|
"@nanoforge-dev/utils-eslint-config": "^1.0.2",
|
|
61
63
|
"@nanoforge-dev/utils-prettier-config": "^1.0.2",
|
|
62
64
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
63
|
-
"@types/node": "^26.
|
|
64
|
-
"@vitest/coverage-v8": "^
|
|
65
|
+
"@types/node": "^26.6.2",
|
|
66
|
+
"@vitest/coverage-v8": "^5.0.1",
|
|
65
67
|
"cpx2": "^9.0.0",
|
|
66
|
-
"eslint": "^10.
|
|
68
|
+
"eslint": "^10.11.0",
|
|
67
69
|
"husky": "^9.1.7",
|
|
68
|
-
"lint-staged": "^17.
|
|
69
|
-
"prettier": "^3.9.
|
|
70
|
-
"tsdown": "^0.
|
|
70
|
+
"lint-staged": "^17.5.1",
|
|
71
|
+
"prettier": "^3.9.9",
|
|
72
|
+
"tsdown": "^0.23.0",
|
|
71
73
|
"typescript": "^6.0.3",
|
|
72
|
-
"vitest": "^
|
|
74
|
+
"vitest": "^5.0.1"
|
|
73
75
|
},
|
|
74
76
|
"engines": {
|
|
75
|
-
"node": "
|
|
77
|
+
"node": "26"
|
|
76
78
|
},
|
|
77
79
|
"publishConfig": {
|
|
78
80
|
"access": "public"
|
|
@@ -93,7 +95,7 @@
|
|
|
93
95
|
"copy:lib": "cpx 'src/libs/**/files/**/{.,}*' dist/libs",
|
|
94
96
|
"lint": "prettier --check . && eslint --format=pretty src",
|
|
95
97
|
"format": "prettier --write . && eslint --fix --format=pretty src",
|
|
96
|
-
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r
|
|
98
|
+
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'libs/schematics/*'",
|
|
97
99
|
"release": "cliff-jumper",
|
|
98
100
|
"test": "pnpm run test:unit && pnpm run test:e2e",
|
|
99
101
|
"test:unit": "vitest run -c vitest.config.ts",
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Rule } from "@angular-devkit/schematics";
|
|
2
|
-
|
|
3
|
-
//#region src/libs/application/application.schema.d.ts
|
|
4
|
-
interface ApplicationSchema {
|
|
5
|
-
/**
|
|
6
|
-
* NanoForge application name
|
|
7
|
-
*/
|
|
8
|
-
name: string;
|
|
9
|
-
/**
|
|
10
|
-
* NanoForge application version
|
|
11
|
-
*/
|
|
12
|
-
version?: string;
|
|
13
|
-
/**
|
|
14
|
-
* NanoForge application author
|
|
15
|
-
*/
|
|
16
|
-
author?: string;
|
|
17
|
-
/**
|
|
18
|
-
* NanoForge application description
|
|
19
|
-
*/
|
|
20
|
-
description?: string;
|
|
21
|
-
/**
|
|
22
|
-
* NanoForge application destination directory
|
|
23
|
-
*/
|
|
24
|
-
directory?: string;
|
|
25
|
-
/**
|
|
26
|
-
* NanoForge Application language
|
|
27
|
-
*/
|
|
28
|
-
language?: "js" | "ts";
|
|
29
|
-
/**
|
|
30
|
-
* With strict mode (TypeScript or JavaScript but only on compatible editor)
|
|
31
|
-
*/
|
|
32
|
-
strict?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Generate lint files
|
|
35
|
-
*/
|
|
36
|
-
lint?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* The used package manager
|
|
39
|
-
*/
|
|
40
|
-
packageManager?: "npm" | "yarn" | "pnpm" | "bun";
|
|
41
|
-
/**
|
|
42
|
-
* Configure a server for the application
|
|
43
|
-
*/
|
|
44
|
-
server?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Add editor dependencies
|
|
47
|
-
*/
|
|
48
|
-
editor: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Add init functions to the application
|
|
51
|
-
*/
|
|
52
|
-
initFunctions: boolean;
|
|
53
|
-
}
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/libs/application/application.factory.d.ts
|
|
56
|
-
declare const main: (schema: ApplicationSchema) => Rule;
|
|
57
|
-
//#endregion
|
|
58
|
-
export { main };
|
|
59
|
-
//# sourceMappingURL=application.factory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;ECyDD;AAAA;;EDpDCC,MAAAA;;;;EAKAC,IAAAA;;;;EAKAC,cAAAA;;;;EAKAC,MAAAA;;;;EAKAC,MAAAA;;;;EAKAC,aAAAA;AAAAA;;;cCJW,IAAA,GAAQ,MAAA,EAAQ,iBAAA,KAAoB,IA+BhD"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { join, normalize, strings } from "@angular-devkit/core";
|
|
2
|
-
import { apply, mergeWith, move, renameTemplateFiles, template, url } from "@angular-devkit/schematics";
|
|
3
|
-
import { firstValueFrom } from "rxjs";
|
|
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
|
-
};
|
|
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
|
-
if (options.packageManager !== "pnpm") tree.delete(join(basePath, "pnpm-workspace.yaml"));
|
|
51
|
-
return tree;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
//#endregion
|
|
55
|
-
export { main };
|
|
56
|
-
|
|
57
|
-
//# sourceMappingURL=application.factory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 if (options.packageManager !== \"pnpm\") {\n tree.delete(join(basePath, \"pnpm-workspace.yaml\"));\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,CAAC,CAAC,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,IAAI,QAAQ,mBAAmB,QAC7B,KAAK,OAAO,KAAK,UAAU,qBAAqB,CAAC;EAGnD,OAAO;CACT;AACF"}
|