@acorex/platform-generator 21.0.0-next.3 → 21.0.0-next.33
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 +67 -6
- package/package.json +9 -3
- package/src/bin/create-acorex-app.js +116 -0
- package/src/bin/standalone-scaffold.js +533 -0
- package/src/generators/app-module/files/project.json.template +194 -48
- package/src/generators/app-module/files/src/app/app.config.api.ts.template +145 -0
- package/src/generators/app-module/files/src/app/app.config.full.ts.template +216 -0
- package/src/generators/app-module/files/src/app/app.config.minimal.ts.template +162 -0
- package/src/generators/app-module/files/src/app/app.routes.ts.template +1 -1
- package/src/generators/app-module/files/src/app/modules/common/default-settings.providers.ts.template +16 -8
- package/src/generators/app-module/files/src/app/modules/layout/layout-root.module.ts.template +3 -6
- package/src/generators/app-module/files/src/app/modules/root/root.module.ts.template +2 -2
- package/src/generators/app-module/files/src/assets/i18n/en-US/activity-log.json +10 -1
- package/src/generators/app-module/files/src/assets/i18n/en-US/auth.json +12 -0
- package/src/generators/app-module/files/src/assets/i18n/en-US/data-management.json +4 -0
- package/src/generators/app-module/files/src/assets/i18n/en-US/general.json +5 -0
- package/src/generators/app-module/files/src/assets/i18n/en-US/organization-management.json +0 -8
- package/src/generators/app-module/files/src/assets/i18n/en-US/questionnaire.json +77 -0
- package/src/generators/app-module/files/src/assets/i18n/fa-IR/activity-log.json +10 -1
- package/src/generators/app-module/files/src/assets/i18n/fa-IR/auth.json +12 -0
- package/src/generators/app-module/files/src/assets/i18n/fa-IR/data-management.json +5 -1
- package/src/generators/app-module/files/src/assets/i18n/fa-IR/general.json +7 -3
- package/src/generators/app-module/files/src/assets/i18n/fa-IR/human-capital-management.json +4 -7
- package/src/generators/app-module/files/src/assets/i18n/fa-IR/organization-management.json +0 -8
- package/src/generators/app-module/files/src/assets/i18n/fa-IR/questionnaire.json +77 -0
- package/src/generators/app-module/files/src/environments/environment.dev.ts.template +45 -16
- package/src/generators/app-module/files/src/environments/environment.prod.ts.template +33 -0
- package/src/generators/app-module/files/src/environments/environment.ts.template +23 -7
- package/src/generators/app-module/files/src/main.ts.template +42 -2
- package/src/generators/app-module/generator.d.ts +10 -1
- package/src/generators/app-module/generator.js +100 -12
- package/src/generators/app-module/generator.js.map +1 -1
- package/src/generators/app-module/schema.d.ts +28 -0
- package/src/generators/app-module/schema.json +74 -5
- package/src/generators/standalone-workspace/versions.json +53 -0
- package/src/generators/app-module/files/src/app/app.config.ts.template +0 -158
package/README.md
CHANGED
|
@@ -1,11 +1,72 @@
|
|
|
1
|
-
# generator
|
|
1
|
+
# @acorex/platform-generator
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Nx schematics for ACoreX Platform **and** a standalone CLI that scaffolds a **new** Nx + Angular workspace using **published** `@acorex/*` packages from the npm registry (no local monorepo clone required).
|
|
4
4
|
|
|
5
|
-
## Building
|
|
5
|
+
## Building (this monorepo)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```bash
|
|
8
|
+
nx build generator
|
|
9
|
+
```
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## Published CLI (npm consumers)
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
Install is optional; `npx` downloads the package on demand.
|
|
14
|
+
|
|
15
|
+
### Standard commands
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Recommended: explicit binary from the published package
|
|
19
|
+
npx @acorex/platform-generator@latest acorex-platform my-app "My App"
|
|
20
|
+
|
|
21
|
+
# Same entry as above (direct script)
|
|
22
|
+
npx @acorex/platform-generator@latest ./my-app "My App" --preset=minimal --connectivity=mock
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The `acorex-platform` binary scaffolds a folder with `package.json`, `nx.json`, `apps/<folder-name>/…`, then runs `npm install` unless you pass `--skip-install`.
|
|
26
|
+
|
|
27
|
+
### Router binary (`create-acorex-app`)
|
|
28
|
+
|
|
29
|
+
`create-acorex-app` chooses the workflow automatically:
|
|
30
|
+
|
|
31
|
+
| Situation | Behavior |
|
|
32
|
+
|-----------|----------|
|
|
33
|
+
| Current directory is **inside** an Nx workspace that contains `nx.json` | Delegates to `nx g @acorex-platform/generator:create-app` (adds `apps/<name>` in this repo). |
|
|
34
|
+
| Not in such a workspace (e.g. empty folder) | Runs the **standalone** scaffold (registry dependencies). |
|
|
35
|
+
| You want the Nx generator **explicitly** | Pass `--monorepo` (requires `--workspace` or `ACOREX_PLATFORM_ROOT` if not already inside the repo). |
|
|
36
|
+
| You are inside a monorepo but want a **standalone** project elsewhere | Pass `--standalone` (ignores the detected workspace for routing). |
|
|
37
|
+
|
|
38
|
+
### `npm create` / `npm init`
|
|
39
|
+
|
|
40
|
+
The npm initializer for scoped packages expects a companion package named `@acorex/create-platform-generator`. Until that package exists, use `npx @acorex/platform-generator@latest acorex-platform …` as above.
|
|
41
|
+
|
|
42
|
+
### Registry and versions
|
|
43
|
+
|
|
44
|
+
Standalone projects resolve `@acorex/platform`, `@acorex/modules`, `@acorex/connectivity`, `@acorex/components`, etc. from npm. Version ranges are defined in `src/generators/standalone-workspace/versions.json` — **keep them aligned** with what you actually publish for each release.
|
|
45
|
+
|
|
46
|
+
### Publish checklist (maintainers)
|
|
47
|
+
|
|
48
|
+
- `@acorex/platform`, `@acorex/modules`, `@acorex/connectivity` (and other `@acorex/*` deps listed in `versions.json`) are published with compatible `exports` / secondary entry points for app imports.
|
|
49
|
+
- Bump `versions.json` to match published semver.
|
|
50
|
+
- Run `nx build generator` so templates and `src/bin/*.js` are copied into `dist/generator` before `npm publish` from the built artifact per your release process.
|
|
51
|
+
|
|
52
|
+
## Internal development (this repo)
|
|
53
|
+
|
|
54
|
+
From the repository root, creating an app **inside** `apps/` uses the Nx generator (workspace is detected automatically):
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npm run create-app -- myapp "My App"
|
|
58
|
+
# same as:
|
|
59
|
+
npx nx g @acorex-platform/generator:create-app myapp "My App"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
To force the **standalone** scaffold while your shell is inside this repo:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
node generator/src/bin/create-acorex-app.js ../path/to/new-folder "My App" --standalone
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Unit tests
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
nx test generator
|
|
72
|
+
```
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acorex/platform-generator",
|
|
3
|
-
"version": "21.0.0-next.
|
|
3
|
+
"version": "21.0.0-next.33",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@acorex/modules": "21.0.0-next.
|
|
5
|
+
"@acorex/modules": "21.0.0-next.33"
|
|
6
|
+
},
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"ejs": "^3.1.10"
|
|
6
9
|
},
|
|
7
10
|
"type": "commonjs",
|
|
8
11
|
"main": "./src/index.js",
|
|
@@ -10,7 +13,10 @@
|
|
|
10
13
|
"private": false,
|
|
11
14
|
"generators": "./generators.json",
|
|
12
15
|
"bin": {
|
|
13
|
-
"
|
|
16
|
+
"acorex-platform": "./src/bin/standalone-scaffold.js",
|
|
17
|
+
"acx-create-entity": "./src/bin/interactive-entity-creator.js",
|
|
18
|
+
"create-acorex-app": "./src/bin/create-acorex-app.js",
|
|
19
|
+
"acx-create-app": "./src/bin/create-acorex-app.js"
|
|
14
20
|
},
|
|
15
21
|
"sideEffects": false,
|
|
16
22
|
"types": "./src/index.d.ts"
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Creates an ACoreX Platform app either:
|
|
4
|
+
* - Inside this monorepo (Nx generator) when a workspace with nx.json is resolved, unless --standalone
|
|
5
|
+
* - As a standalone npm workspace (registry deps) when no workspace is found, or with --standalone
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* create-acorex-app <appName> "<appTitle>" [options]
|
|
9
|
+
* create-acorex-app <project-dir> "<title>" --standalone [standalone options]
|
|
10
|
+
*
|
|
11
|
+
* Monorepo (Nx):
|
|
12
|
+
* create-acorex-app myapp "My App" --workspace=C:\path\to\acorex-platform
|
|
13
|
+
* create-acorex-app myapp "My App" # from a directory inside the cloned repo
|
|
14
|
+
* create-acorex-app myapp "My App" --monorepo
|
|
15
|
+
*
|
|
16
|
+
* Standalone (no local clone):
|
|
17
|
+
* create-acorex-app my-app "My App" --standalone
|
|
18
|
+
* # or from a directory that is not inside an Nx workspace:
|
|
19
|
+
* create-acorex-app my-app "My App"
|
|
20
|
+
*/
|
|
21
|
+
const { spawnSync } = require('child_process');
|
|
22
|
+
const fs = require('fs');
|
|
23
|
+
const path = require('path');
|
|
24
|
+
|
|
25
|
+
const { runStandalone } = require('./standalone-scaffold');
|
|
26
|
+
|
|
27
|
+
function findWorkspaceRoot(startDir) {
|
|
28
|
+
let dir = path.resolve(startDir);
|
|
29
|
+
for (;;) {
|
|
30
|
+
if (fs.existsSync(path.join(dir, 'nx.json'))) {
|
|
31
|
+
return dir;
|
|
32
|
+
}
|
|
33
|
+
const parent = path.dirname(dir);
|
|
34
|
+
if (parent === dir) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
dir = parent;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Strips workspace flags and returns { workspaceRoot, nxArgs }.
|
|
43
|
+
*/
|
|
44
|
+
function parseCli(argv) {
|
|
45
|
+
let workspaceRoot = process.env.ACOREX_PLATFORM_ROOT ? path.resolve(process.env.ACOREX_PLATFORM_ROOT) : null;
|
|
46
|
+
const nxArgs = [];
|
|
47
|
+
|
|
48
|
+
for (let i = 0; i < argv.length; i++) {
|
|
49
|
+
const a = argv[i];
|
|
50
|
+
if (a === '--workspace' && argv[i + 1]) {
|
|
51
|
+
workspaceRoot = path.resolve(argv[i + 1]);
|
|
52
|
+
i++;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (a.startsWith('--workspace=')) {
|
|
56
|
+
workspaceRoot = path.resolve(a.slice('--workspace='.length));
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
nxArgs.push(a);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!workspaceRoot) {
|
|
63
|
+
workspaceRoot = findWorkspaceRoot(process.cwd());
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return { workspaceRoot, nxArgs };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function stripRoutingFlags(argv) {
|
|
70
|
+
const out = [];
|
|
71
|
+
for (let i = 0; i < argv.length; i++) {
|
|
72
|
+
const a = argv[i];
|
|
73
|
+
if (a === '--standalone' || a === '--monorepo') {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
out.push(a);
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const rawArgv = process.argv.slice(2);
|
|
82
|
+
const forceStandalone = rawArgv.includes('--standalone');
|
|
83
|
+
const forceMonorepo = rawArgv.includes('--monorepo');
|
|
84
|
+
const argv = stripRoutingFlags(rawArgv);
|
|
85
|
+
|
|
86
|
+
const { workspaceRoot, nxArgs } = parseCli(argv);
|
|
87
|
+
|
|
88
|
+
const hasValidWorkspace = Boolean(workspaceRoot && fs.existsSync(path.join(workspaceRoot, 'nx.json')));
|
|
89
|
+
|
|
90
|
+
if (forceMonorepo && !hasValidWorkspace) {
|
|
91
|
+
console.error(
|
|
92
|
+
[
|
|
93
|
+
'[create-acorex-app] --monorepo requires an Nx workspace (nx.json).',
|
|
94
|
+
' Pass --workspace=<path-to-acorex-platform> or set ACOREX_PLATFORM_ROOT.',
|
|
95
|
+
].join('\n'),
|
|
96
|
+
);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const useNxGenerator = forceMonorepo || (!forceStandalone && hasValidWorkspace);
|
|
101
|
+
|
|
102
|
+
if (!useNxGenerator) {
|
|
103
|
+
runStandalone(argv);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const nxForward = ['nx', 'g', '@acorex-platform/generator:create-app', ...nxArgs];
|
|
108
|
+
const isWindows = process.platform === 'win32';
|
|
109
|
+
const cmd = isWindows ? 'npx.cmd' : 'npx';
|
|
110
|
+
const result = spawnSync(cmd, nxForward, {
|
|
111
|
+
cwd: workspaceRoot,
|
|
112
|
+
stdio: 'inherit',
|
|
113
|
+
shell: isWindows,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
process.exit(result.status === null ? 1 : result.status);
|