@impactor/nx-manager 2.0.4 → 3.0.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/executors.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "executors": {
3
+ "universal-builder": {
4
+ "implementation": "./src/executors/universal-builder/universal-builder",
5
+ "schema": "./src/executors/universal-builder/schema.json",
6
+ "description": "universal-builder executor"
7
+ }
8
+ }
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@impactor/nx-manager",
3
- "version": "2.0.4",
3
+ "version": "3.0.0",
4
4
  "description": "NX generators and executors",
5
5
  "type": "module",
6
6
  "private": false,
@@ -11,11 +11,19 @@
11
11
  "nx": {
12
12
  "projectType": "library",
13
13
  "targets": {
14
- "build": {}
14
+ "build": {
15
+ "options": {
16
+ "postBuild": [
17
+ "default",
18
+ "{workspaceRoot}/tasks/post-build.ts",
19
+ "{projectRoot}/post-build.ts"
20
+ ]
21
+ }
22
+ }
15
23
  }
16
24
  },
17
25
  "imports": {
18
- "#*": "./src/*"
26
+ "#*": "./*"
19
27
  },
20
28
  "exports": {
21
29
  ".": {
@@ -34,16 +42,13 @@
34
42
  "types": "./index.d.ts",
35
43
  "main": "./index.js",
36
44
  "dependencies": {
37
- "@nx/angular": "22.3.3",
38
- "@nx/devkit": "22.4.5",
39
- "@nx/esbuild": "22.4.5",
45
+ "@nx/angular": "22.5.0",
46
+ "@nx/devkit": "22.5.0",
47
+ "@nx/esbuild": "22.5.0",
40
48
  "tslib": "^2.8.1"
41
49
  },
42
50
  "executors": "./executors.json",
43
- "devDependencies": {
44
- "@nestjs/cli": "^11.0.16",
45
- "esbuild": "^0.27.2"
46
- },
51
+ "devDependencies": {},
47
52
  "engines": {
48
53
  "node": "^18.19.1 || ^20.11.1 || >=22.0.0"
49
54
  },
@@ -69,5 +74,7 @@
69
74
  "url": "https://www.patreon.com/GoogleDev"
70
75
  }
71
76
  ],
72
- "scripts": {}
77
+ "scripts": {
78
+ "start": "NODE_ENV=production pnpm tsx --env-file-if-exists=.env --env-file-if-exists=.env.local --env-file-if-exists=.env.production --env-file-if-exists=.env.production.local main.js"
79
+ }
73
80
  }
@@ -9,7 +9,7 @@ export declare function buildAngularLibrary(options: IBuildAngularNormalizedOpti
9
9
  export declare function buildAngularApp(options: IBuildAngularNormalizedOptions, ctx: ExecutorContext): Promise<{
10
10
  success: boolean;
11
11
  }>;
12
- export declare function getOptions(options: IBuildAngularOptions, _ctx: ExecutorContext): Promise<IBuildAngularNormalizedOptions>;
12
+ export declare function getOptions(options: IBuildAngularOptions, _ctx: ExecutorContext): IBuildAngularNormalizedOptions;
13
13
  export declare function getLibraryOptions(options: IBuildAngularNormalizedOptions, _ctx: ExecutorContext): IBuildAngularLibraryOptions;
14
14
  export declare function getAppOptions(options: IBuildAngularNormalizedOptions, _ctx: ExecutorContext): IBuildAngularAppOptions & {
15
15
  tsConfig: string;
@@ -4,7 +4,7 @@ import { getTsConfigFile } from "../utils/get-tsconfig-file";
4
4
  import { relative } from "node:path";
5
5
  import { readJSON } from "../utils/fs";
6
6
  async function build(options, ctx) {
7
- let opts = await getOptions(options, ctx);
7
+ let opts = getOptions(options, ctx);
8
8
  if (opts.projectType === "library") return buildAngularLibrary(opts, ctx);
9
9
  if (opts.projectType === "application") return buildAngularApp(opts, ctx);
10
10
  return { success: false };
@@ -19,25 +19,13 @@ async function buildAngularLibrary(options, ctx) {
19
19
  }
20
20
  async function buildAngularApp(options, ctx) {
21
21
  let opts = getAppOptions(options, ctx);
22
- if (opts.outputMode) {
23
- console.warn(
24
- `The option outputMode is currently not supported, it will be ignored`
25
- );
26
- delete opts.outputMode;
27
- }
28
- if (opts.ssr && typeof opts.ssr !== "boolean") {
29
- console.warn(
30
- `The option ssr curently support boolean values only, it'll considered as true`
31
- );
32
- opts.ssr = true;
33
- }
34
22
  let results = await applicationExecutor(opts, ctx);
35
23
  for await (let result of results) {
36
24
  if (!result.success) return { success: false };
37
25
  }
38
26
  return { success: true };
39
27
  }
40
- async function getOptions(options, _ctx) {
28
+ function getOptions(options, _ctx) {
41
29
  let opts = { ...options };
42
30
  if (!opts.angularConfigs) {
43
31
  opts.angularConfigs = readJSON(
@@ -57,7 +45,8 @@ async function getOptions(options, _ctx) {
57
45
  }
58
46
  let tsConfig = (
59
47
  // todo: remove `./`
60
- opts.tsConfig || opts.angularConfigs?.projects?.[opts.projectName]?.tsConfig || getTsConfigFile(opts)
48
+ opts.tsConfig || // @ts-ignore
49
+ opts.angularConfigs?.projects?.[opts.projectName]?.tsConfig || getTsConfigFile(opts)
61
50
  );
62
51
  let relativeProjectPath = relative(opts.root, opts.projectPath);
63
52
  opts.tsConfig = `${relativeProjectPath}/${tsConfig}`;
@@ -15,8 +15,7 @@ export declare function getTargetOptions(opts: IBuildEsbuildOptions, ctx: Execut
15
15
  flags: string[];
16
16
  root: string;
17
17
  outDir?: string;
18
- postBuild?: boolean | string;
19
- forceRnDefaultPostBuild?: true;
18
+ postBuild?: string[] | null;
20
19
  mode?: "development" | "production";
21
20
  cwd?: string;
22
21
  additionalEntryPoints?: string[] | undefined;
@@ -1,4 +1,4 @@
1
- import { copyFileSync, existsSync, readdirSync, writeFileSync } from "node:fs";
1
+ import { copyFileSync, existsSync, readdirSync } from "node:fs";
2
2
  import { resolve } from "node:path";
3
3
  import { readJSON, writeJSON } from "./utils/fs";
4
4
  function postBuild(options) {
@@ -76,19 +76,6 @@ function postBuild(options) {
76
76
  copyFileSync(`${opts.projectPath}/${file}`, `${dist}/${file}`);
77
77
  }
78
78
  });
79
- if (existsSync(`${opts.projectPath}/project.json`)) {
80
- copyFileSync(`${opts.projectPath}/project.json`, `${dist}/project.json`);
81
- }
82
- if (existsSync(`${opts.root}/nx.json`)) {
83
- copyFileSync(`${opts.root}/nx.json`, `${dist}/nx.json`);
84
- }
85
- if (!existsSync(`${dist}/main.js`)) {
86
- if (existsSync(`${dist}/server/server.mjs`)) {
87
- writeFileSync(`${dist}/main.js`, `import "./server/server.mjs"`);
88
- } else if (existsSync(`${dist}/server/server.js`)) {
89
- writeFileSync(`${dist}/main.js`, `import "./server/server.js"`);
90
- }
91
- }
92
79
  }
93
80
  export {
94
81
  postBuild as default
@@ -36,32 +36,36 @@ const run = async (options, ctx) => {
36
36
  );
37
37
  }
38
38
  if (!result.success) return result;
39
- if (opts.postBuild) {
40
- console.info(`[universal-builder] executing postbuild`, opts.postBuild);
41
- if (Array.isArray(opts.postBuild)) {
42
- await exec(opts.postBuild[0], opts.postBuild[1]);
43
- } else {
39
+ if (opts.postBuild !== null) {
40
+ console.info(`[universal-builder] executing postbuild commands`);
41
+ if (!opts.postBuild) {
42
+ opts.postBuild = ["default", "script:postbuild"];
44
43
  }
45
- } else if (options.postBuild !== false) {
46
- if (opts.forceRnDefaultPostBuild) {
47
- await import("./post-build").then((m) => m.default(opts));
48
- }
49
- console.info(
50
- `[universal-builder] executing the script postbuild (if exists)`
51
- );
52
- let pkg = JSON.parse(
53
- readFileSync(`${opts.projectPath}/package.json`, "utf8")
54
- );
55
- if (pkg.scripts?.postbuild) {
56
- await exec(
57
- // todo: detect the package manager (may be NX already provide it with opts)
58
- "pnpm",
59
- ["run", "postbuild"],
60
- // the script should be executed from the project root even if opts.cwd is not specified
61
- opts.projectPath
62
- );
63
- } else if (!opts.forceRnDefaultPostBuild) {
64
- await import("./post-build").then((m) => m.default(opts));
44
+ for (let item of opts.postBuild) {
45
+ if (item.toLowerCase() === "default") {
46
+ await import("./post-build").then((m) => m.default(opts));
47
+ } else if (item.toLowerCase().startsWith("script:")) {
48
+ let script = item.split(":").slice().join("");
49
+ console.info(
50
+ `[universal-builder] executing the script ${script} (if exists)`
51
+ );
52
+ let pkg = JSON.parse(
53
+ readFileSync(`${opts.projectPath}/package.json`, "utf8")
54
+ );
55
+ if (pkg.scripts?.[script]) {
56
+ await exec(
57
+ // todo: detect the package manager (may be NX already provide it with opts)
58
+ "pnpm",
59
+ ["run", script],
60
+ // the script should be executed from the project root even if opts.cwd is not specified
61
+ opts.projectPath
62
+ );
63
+ }
64
+ } else if (item.endsWith(".js") || item.endsWith(".ts")) {
65
+ await import(`${opts.root}/${item}`).then((m) => m.default(opts));
66
+ } else {
67
+ await exec(item, void 0, opts.projectPath);
68
+ }
65
69
  }
66
70
  }
67
71
  if (opts.cwd && opts.cwd !== originalCwd) {
package/nx.json DELETED
@@ -1,174 +0,0 @@
1
- {
2
- "$schema": "./node_modules/nx/schemas/nx-schema.json",
3
- "targetDefaults": {
4
- "build": {
5
- "executor": "@impactor/nx-manager:universal-builder",
6
- "dependsOn": ["typecheck", "prebuild", "^build"],
7
- "cache": true,
8
- "inputs": ["default", "^default"],
9
- "outputs": ["{projectRoot}/dist"],
10
- "options": {
11
- "forceRnDefaultPostBuild": true
12
- }
13
- },
14
- "serve": {
15
- "executor": "nx:run-commands",
16
- "dependsOn": ["build", "preserve"],
17
- "continuous": true,
18
- "options": {
19
- "cwd": "{projectRoot}",
20
- "command": "NODE_ENV=development pnpm tsx --env-file-if-exists=.env --env-file-if-exists=.env.local dist/main.js"
21
- },
22
- "configurations": {
23
- "production": {
24
- "command": "NODE_ENV=production pnpm tsx --env-file-if-exists=.env --env-file-if-exists=.env.local --env-file-if-exists=.env.production --env-file-if-exists=.env.production.local dist/main.js"
25
- }
26
- }
27
- },
28
- "nx-release-publish": {
29
- "options": {
30
- "packageRoot": "{projectRoot}/dist"
31
- }
32
- },
33
- "test": {
34
- "inputs": ["test"],
35
- "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
36
- "dependsOn": ["^build", "pretest"],
37
- "configurations": {
38
- "unit": {
39
- "args": [
40
- "--testPathIgnorePatterns '.*\\.e2e\\.spec\\.ts$'",
41
- "--testPathIgnorePatterns '/.*-e2e/'",
42
- "--testPathIgnorePatterns '/.*-e2e/'"
43
- ]
44
- },
45
- "e2e": {
46
- "args": [
47
- "--testMatch '**/*-e2e/**/*.{spec,test}.[mc]?[jt]s?(x)'",
48
- "--testMatch '**/e2e/**/*.{spec,test}.[mc]?[jt]s?(x)'",
49
- "--testMatch '**/*.e2e.(spec|test).?([mc])[jt]s?(x)'"
50
- ]
51
- }
52
- }
53
- },
54
- "@angular/build:application": {
55
- "cache": true,
56
- "dependsOn": ["prebuild", "^build"],
57
- "inputs": ["default", "^default"]
58
- },
59
- "@nx/angular:package": {
60
- "cache": true,
61
- "dependsOn": ["^build"],
62
- "inputs": ["default", "^default"],
63
- "outputs": ["{projectRoot}/dist"],
64
- "options": {
65
- "project": "{projectRoot}/ng-package.json",
66
- "tsConfig": "{projectRoot}/tsconfig.lib.json"
67
- }
68
- },
69
- "@nx/js:tsc": {
70
- "cache": true,
71
- "dependsOn": ["^build"],
72
- "inputs": ["default", "^default"]
73
- }
74
- },
75
- "namedInputs": {
76
- "default": [
77
- "{projectRoot}/src/**/*",
78
- "!{projectRoot}/**/*.(spec|test)(.e2e)?.[tj]sx?",
79
- "!{projectRoot}/**/e2e/**/*",
80
- "{projectRoot}/.env(.*)?",
81
- "{workspaceRoot}/tasks/(post-)?build.ts",
82
- "{projectRoot}/(project|package|tsconfig)(.+)?.json",
83
- "{workspaceRoot}/tsconfig.base.json",
84
- {
85
- "runtime": "node --version"
86
- },
87
- {
88
- "env": "NODE_ENV"
89
- }
90
- ],
91
- "test": [
92
- "default",
93
- "{projectRoot}/tsconfig.spec.json",
94
- "{projectRoot}/jest.config.[jt]s",
95
- "{workspaceRoot}/jest.config.[jt]s",
96
- "{projectRoot}/**/*.(spec|test)(.e2e)?.[jt]sx?",
97
- "{projectRoot}/**/e2e/**/*.[jt]sx?",
98
- {
99
- "externalDependencies": ["jest"]
100
- }
101
- ]
102
- },
103
- "plugins": [
104
- {
105
- "plugin": "@nx/js/typescript",
106
- "options": {
107
- "typecheck": {
108
- "targetName": "typecheck"
109
- },
110
- "build": false
111
- }
112
- },
113
- {
114
- "plugin": "@nx/jest/plugin",
115
- "options": {
116
- "targetName": "test",
117
- "ciTargetName": "test-ci"
118
- }
119
- }
120
- ],
121
- "tasksRunnerOptions": {
122
- "default": {
123
- "options": {
124
- "useDaemonProcess": false
125
- }
126
- }
127
- },
128
- "generators": {
129
- "@nx/angular:library": {
130
- "linter": "eslint",
131
- "unitTestRunner": "jest"
132
- },
133
- "@nx/angular:component": {
134
- "style": "scss"
135
- }
136
- },
137
- "release": {
138
- "groups": {
139
- "libs": {
140
- "projects": ["libs/*"]
141
- },
142
- "apps": {
143
- "projects": ["apps/*"],
144
- "changelog": {
145
- "projectChangelogs": {
146
- "createRelease": "github"
147
- }
148
- }
149
- }
150
- },
151
- "projectsRelationship": "independent",
152
- "version": {
153
- "conventionalCommits": true,
154
- "updateDependents": "always",
155
- "preVersionCommand": "pnpm nx run-many -t build",
156
- "manifestRootsToUpdate": [
157
- "{projectRoot}",
158
- {
159
- "path": "{projectRoot}/dist",
160
- "preserveLocalDependencyProtocols": false
161
- }
162
- ]
163
- },
164
- "releaseTag": {
165
- "pattern": "{projectName}@{version}"
166
- },
167
- "changelog": {
168
- "projectChangelogs": true
169
- }
170
- },
171
- "sync": {
172
- "applyChanges": false
173
- }
174
- }