@nx/js 22.7.0-beta.5 → 22.7.0-beta.6

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/assets.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "outDir": "dist/packages/js",
3
+ "assets": [
4
+ {
5
+ "glob": "**/files/**"
6
+ },
7
+ {
8
+ "glob": "**/files/**/.gitkeep"
9
+ },
10
+ {
11
+ "glob": "**/*.json",
12
+ "ignore": ["tsconfig*.json", "project.json", ".eslintrc.json"]
13
+ },
14
+ {
15
+ "glob": "**/*.js",
16
+ "ignore": ["**/jest.config.js", "src/index.js"]
17
+ },
18
+ {
19
+ "glob": "**/*.d.ts"
20
+ },
21
+ "LICENSE"
22
+ ]
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/js",
3
- "version": "22.7.0-beta.5",
3
+ "version": "22.7.0-beta.6",
4
4
  "private": false,
5
5
  "description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
6
6
  "repository": {
@@ -19,7 +19,8 @@
19
19
  "Backend"
20
20
  ],
21
21
  "main": "src/index.js",
22
- "typings": "src/index.d.ts",
22
+ "type": "commonjs",
23
+ "types": "src/index.d.ts",
23
24
  "license": "MIT",
24
25
  "bugs": {
25
26
  "url": "https://github.com/nrwl/nx/issues"
@@ -39,8 +40,8 @@
39
40
  "@babel/preset-env": "^7.23.2",
40
41
  "@babel/preset-typescript": "^7.22.5",
41
42
  "@babel/runtime": "^7.22.6",
42
- "@nx/devkit": "22.7.0-beta.5",
43
- "@nx/workspace": "22.7.0-beta.5",
43
+ "@nx/devkit": "22.7.0-beta.6",
44
+ "@nx/workspace": "22.7.0-beta.6",
44
45
  "@zkochan/js-yaml": "0.0.7",
45
46
  "babel-plugin-const-enum": "^1.0.1",
46
47
  "babel-plugin-macros": "^3.1.0",
@@ -60,7 +61,7 @@
60
61
  "tslib": "^2.3.0"
61
62
  },
62
63
  "devDependencies": {
63
- "nx": "22.7.0-beta.5"
64
+ "nx": "22.7.0-beta.6"
64
65
  },
65
66
  "peerDependencies": {
66
67
  "verdaccio": "^6.0.5"
@@ -72,7 +73,5 @@
72
73
  },
73
74
  "publishConfig": {
74
75
  "access": "public"
75
- },
76
- "types": "src/index.d.ts",
77
- "type": "commonjs"
76
+ }
78
77
  }
@@ -1,5 +1,8 @@
1
1
  import { AssetGlob } from './assets';
2
+ import { normalizeAssets, getAssetOutputPath, NormalizedAssetEntry as AssetEntry } from './normalize-assets';
2
3
  import { ChangedFile } from 'nx/src/daemon/client/client';
4
+ export type { AssetEntry };
5
+ export { normalizeAssets, getAssetOutputPath };
3
6
  export type FileEventType = 'create' | 'update' | 'delete';
4
7
  export interface FileEvent {
5
8
  type: FileEventType;
@@ -32,5 +35,4 @@ export declare class CopyAssetsHandler {
32
35
  private filesToEvent;
33
36
  private normalizeAssetPattern;
34
37
  }
35
- export {};
36
38
  //# sourceMappingURL=copy-assets-handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"copy-assets-handler.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/assets/copy-assets-handler.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,WAAW,EAAgB,MAAM,6BAA6B,CAAC;AAGxE,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE3D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,uBAAuB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC;IAC/B,QAAQ,CAA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exports, "__esModule", { value: true });
3
- exports.CopyAssetsHandler = exports.defaultFileEventHandler = void 0;
3
+ exports.CopyAssetsHandler = exports.defaultFileEventHandler = exports.getAssetOutputPath = exports.normalizeAssets = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const picomatch = require("picomatch");
6
6
  const node_fs_1 = require("node:fs");
@@ -8,6 +8,9 @@ const pathPosix = tslib_1.__importStar(require("node:path/posix"));
8
8
  const path = tslib_1.__importStar(require("node:path"));
9
9
  const ignore_1 = tslib_1.__importDefault(require("ignore"));
10
10
  const tinyglobby_1 = require("tinyglobby");
11
+ const normalize_assets_1 = require("./normalize-assets");
12
+ Object.defineProperty(exports, "normalizeAssets", { enumerable: true, get: function () { return normalize_assets_1.normalizeAssets; } });
13
+ Object.defineProperty(exports, "getAssetOutputPath", { enumerable: true, get: function () { return normalize_assets_1.getAssetOutputPath; } });
11
14
  const devkit_1 = require("@nx/devkit");
12
15
  const client_1 = require("nx/src/daemon/client/client");
13
16
  const picocolors_1 = require("picocolors");
@@ -49,40 +52,7 @@ class CopyAssetsHandler {
49
52
  if ((0, node_fs_1.existsSync)(nxignore)) {
50
53
  this.ignore.add((0, node_fs_1.readFileSync)(nxignore).toString());
51
54
  }
52
- this.assetGlobs = opts.assets.map((f) => {
53
- let isGlob = false;
54
- let pattern;
55
- // Input and output directories are normalized to be relative to root
56
- let input;
57
- let output;
58
- let ignore = null;
59
- let includeIgnoredFiles = undefined;
60
- const resolvedOutputDir = path.isAbsolute(opts.outputDir)
61
- ? opts.outputDir
62
- : path.resolve(opts.rootDir, opts.outputDir);
63
- if (typeof f === 'string') {
64
- pattern = f;
65
- input = path.relative(opts.rootDir, opts.projectDir);
66
- output = path.relative(opts.rootDir, resolvedOutputDir);
67
- }
68
- else {
69
- isGlob = true;
70
- pattern = pathPosix.join(f.input, f.glob);
71
- input = f.input;
72
- output = pathPosix.join(path.relative(opts.rootDir, resolvedOutputDir), f.output);
73
- if (f.ignore)
74
- ignore = f.ignore.map((ig) => pathPosix.join(f.input, ig));
75
- includeIgnoredFiles = f.includeIgnoredFiles;
76
- }
77
- return {
78
- isGlob,
79
- input,
80
- pattern,
81
- ignore,
82
- output,
83
- includeIgnoredFiles,
84
- };
85
- });
55
+ this.assetGlobs = (0, normalize_assets_1.normalizeAssets)(opts.assets, opts.rootDir, opts.projectDir, opts.outputDir);
86
56
  }
87
57
  async processAllAssetsOnce() {
88
58
  await Promise.all(this.assetGlobs.map(async (ag) => {
@@ -181,12 +151,10 @@ class CopyAssetsHandler {
181
151
  if (!assetGlob.ignore?.some((ig) => picomatch(ig)(src)) &&
182
152
  ((assetGlob.includeIgnoredFiles ?? this.includeIgnoredFiles) ||
183
153
  !this.ignore.ignores(src))) {
184
- const relPath = path.relative(assetGlob.input, src);
185
- const dest = relPath.startsWith('..') ? src : relPath;
186
154
  acc.push({
187
155
  type: 'create',
188
156
  src: path.join(this.rootDir, src),
189
- dest: path.join(this.rootDir, assetGlob.output, dest),
157
+ dest: path.join(this.rootDir, (0, normalize_assets_1.getAssetOutputPath)(src, assetGlob)),
190
158
  });
191
159
  }
192
160
  return acc;
@@ -0,0 +1,26 @@
1
+ export interface AssetGlobInput {
2
+ input: string;
3
+ output: string;
4
+ glob: string;
5
+ ignore?: string[];
6
+ includeIgnoredFiles?: boolean;
7
+ }
8
+ export interface NormalizedAssetEntry {
9
+ isGlob: boolean;
10
+ pattern: string;
11
+ ignore: string[] | null;
12
+ input: string;
13
+ output: string;
14
+ includeIgnoredFiles?: boolean;
15
+ }
16
+ /**
17
+ * Normalize raw asset definitions (strings or objects) into resolved
18
+ * entries with computed input, output, and pattern fields.
19
+ */
20
+ export declare function normalizeAssets(assets: (string | AssetGlobInput)[], rootDir: string, projectDir: string, outputDir: string): NormalizedAssetEntry[];
21
+ /**
22
+ * Compute the output path for a file given its asset entry,
23
+ * matching the dest logic used during file copying.
24
+ */
25
+ export declare function getAssetOutputPath(src: string, assetEntry: NormalizedAssetEntry): string;
26
+ //# sourceMappingURL=normalize-assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-assets.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/assets/normalize-assets.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,CAAC,MAAM,GAAG,cAAc,CAAC,EAAE,EACnC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,GAChB,oBAAoB,EAAE,CA8BxB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,oBAAoB,GAC/B,MAAM,CAIR"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeAssets = normalizeAssets;
4
+ exports.getAssetOutputPath = getAssetOutputPath;
5
+ const tslib_1 = require("tslib");
6
+ const path = tslib_1.__importStar(require("node:path"));
7
+ const pathPosix = tslib_1.__importStar(require("node:path/posix"));
8
+ /**
9
+ * Normalize raw asset definitions (strings or objects) into resolved
10
+ * entries with computed input, output, and pattern fields.
11
+ */
12
+ function normalizeAssets(assets, rootDir, projectDir, outputDir) {
13
+ const resolvedOutputDir = path.isAbsolute(outputDir)
14
+ ? outputDir
15
+ : path.resolve(rootDir, outputDir);
16
+ return assets.map((f) => {
17
+ if (typeof f === 'string') {
18
+ return {
19
+ isGlob: false,
20
+ pattern: f,
21
+ input: path.relative(rootDir, projectDir),
22
+ output: path.relative(rootDir, resolvedOutputDir),
23
+ ignore: null,
24
+ includeIgnoredFiles: undefined,
25
+ };
26
+ }
27
+ return {
28
+ isGlob: true,
29
+ pattern: pathPosix.join(f.input, f.glob),
30
+ input: f.input,
31
+ output: pathPosix.join(path.relative(rootDir, resolvedOutputDir), f.output),
32
+ ignore: f.ignore
33
+ ? f.ignore.map((ig) => pathPosix.join(f.input, ig))
34
+ : null,
35
+ includeIgnoredFiles: f.includeIgnoredFiles,
36
+ };
37
+ });
38
+ }
39
+ /**
40
+ * Compute the output path for a file given its asset entry,
41
+ * matching the dest logic used during file copying.
42
+ */
43
+ function getAssetOutputPath(src, assetEntry) {
44
+ const relPath = path.relative(assetEntry.input, src);
45
+ const dest = relPath.startsWith('..') ? src : relPath;
46
+ return pathPosix.join(assetEntry.output, dest);
47
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "compilerOptions": {
3
+ "importHelpers": true
4
+ }
5
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es5",
4
+ "skipLibCheck": true,
5
+ "strict": false,
6
+ "noEmit": true,
7
+ "incremental": false,
8
+ "module": "esnext",
9
+ "moduleResolution": "node"
10
+ }
11
+ }