@plugjs/plug 0.0.6 → 0.0.7

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.
Files changed (45) hide show
  1. package/dist/files.cjs +5 -8
  2. package/dist/files.cjs.map +1 -1
  3. package/dist/files.mjs +5 -8
  4. package/dist/files.mjs.map +1 -1
  5. package/dist/paths.cjs +1 -1
  6. package/dist/paths.cjs.map +1 -1
  7. package/dist/paths.mjs +2 -2
  8. package/dist/paths.mjs.map +1 -1
  9. package/dist/plugs/copy.cjs +6 -12
  10. package/dist/plugs/copy.cjs.map +2 -2
  11. package/dist/plugs/copy.mjs +6 -6
  12. package/dist/plugs/copy.mjs.map +1 -1
  13. package/dist/plugs/esbuild.cjs +0 -1
  14. package/dist/plugs/esbuild.cjs.map +1 -1
  15. package/dist/plugs/esbuild.mjs +0 -1
  16. package/dist/plugs/esbuild.mjs.map +1 -1
  17. package/dist/run.cjs +3 -2
  18. package/dist/run.cjs.map +1 -1
  19. package/dist/run.mjs +4 -3
  20. package/dist/run.mjs.map +1 -1
  21. package/dist/utils/asyncfs.cjs +4 -8
  22. package/dist/utils/asyncfs.cjs.map +2 -2
  23. package/dist/utils/asyncfs.mjs +3 -7
  24. package/dist/utils/asyncfs.mjs.map +2 -2
  25. package/dist/utils/walk.cjs +7 -4
  26. package/dist/utils/walk.cjs.map +1 -1
  27. package/dist/utils/walk.mjs +8 -5
  28. package/dist/utils/walk.mjs.map +1 -1
  29. package/package.json +3 -3
  30. package/src/files.ts +9 -12
  31. package/src/paths.ts +2 -2
  32. package/src/plugs/copy.ts +6 -7
  33. package/src/plugs/esbuild.ts +0 -1
  34. package/src/run.ts +4 -3
  35. package/src/utils/asyncfs.ts +9 -8
  36. package/src/utils/walk.ts +10 -5
  37. package/types/files.d.ts +1 -5
  38. package/types/plugs/esbuild.d.ts +0 -1
  39. package/types/utils/asyncfs.d.ts +2 -5
  40. package/dist/plugs/esbuild/check-dependencies.cjs +0 -140
  41. package/dist/plugs/esbuild/check-dependencies.cjs.map +0 -6
  42. package/dist/plugs/esbuild/check-dependencies.mjs +0 -115
  43. package/dist/plugs/esbuild/check-dependencies.mjs.map +0 -6
  44. package/src/plugs/esbuild/check-dependencies.ts +0 -158
  45. package/types/plugs/esbuild/check-dependencies.d.ts +0 -12
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/utils/walk.ts"],
4
- "mappings": ";AAAA,SAAS,UAAU,YAAY;AAC/B,SAAS,IAAI,WAAW;AACxB,SAAuB,2BAA2B;AAClD,SAAS,SAAS,YAAY;AAC9B,SAAS,aAA2B;AA8B7B,SAAS,KACZ,WACA,OACA,UAAuB,CAAC,GACU;AACpC,QAAM;AAAA,IACJ,WAAW;AAAA,IACX,iBAAiB;AAAA,IACjB,mBAAmB;AAAA,OAChB;AAAA,EACL,IAAI;AAGJ,QAAM,cAAc,CAAC,QAA+B;AAGlD,QAAI,QAAQ;AAAW,aAAO;AAC9B,UAAM,OAAO,SAAS,GAAG;AACzB,QAAI,SAAS;AAAgB,aAAO,CAAC,CAAC;AACtC,QAAI,KAAK,WAAW,GAAG;AAAG,aAAO,CAAC,CAAC,KAAK;AACxC,WAAO;AAAA,EACT;AAGA,QAAM,kBAAkB,MAAM,OAAO,IAAI;AAGzC,MAAI,MAAM,qBAAqB,GAAG,SAAS,GAAG,EAAE,OAAO,QAAQ,CAAC;AAChE,SAAO,OAAO;AAAA,IACZ;AAAA,IACA,UAAU;AAAA,IACV,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,EACT,CAAC;AACH;AAiBA,gBAAgB,OAAO,MAA2D;AAChF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAGJ,QAAM,MAAM,oBAAoB,WAAW,QAAQ;AACnD,MAAI,CAAE,YAAY,GAAG;AAAG;AACx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AI,KAAK,OAAO,KAAK,gBAAgB,IAAI;AAAG,cAAM;AAAA,eAGzC,KAAK,YAAY,KAAM,QAAQ,UAAW;AACjD,cAAM,WAAW,OAAO,EAAE,GAAG,MAAM,UAAU,MAAM,OAAO,QAAQ,EAAE,CAAC;AACrE,yBAAiB,SAAS;AAAU,gBAAM;AAAA,MAC5C;AAAA,IACF;AAAA,EACF;AACF;",
5
5
  "names": []
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plugjs/plug",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "type": "commonjs",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -31,6 +31,7 @@
31
31
  "@babel/parser": "^7.18.11",
32
32
  "@babel/types": "^7.18.10",
33
33
  "@plugjs/cov8-html": "^0.0.1",
34
+ "@types/node": "<17",
34
35
  "diff": "^5.1.0",
35
36
  "esbuild": "^0.15.5",
36
37
  "eslint": "^8.22.0",
@@ -43,10 +44,9 @@
43
44
  "devDependencies": {
44
45
  "@types/chai": "^4.3.3",
45
46
  "@types/diff": "^5.0.2",
46
- "@types/eslint": "^8.4.5",
47
+ "@types/eslint": "^8.4.6",
47
48
  "@types/mocha": "^9.1.1",
48
49
  "@types/ms": "^0.7.31",
49
- "@types/node": "<17",
50
50
  "@types/picomatch": "^2.3.0",
51
51
  "@types/yargs-parser": "^21.0.0",
52
52
  "@typescript-eslint/eslint-plugin": "^5.33.1",
package/src/files.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { inspect } from 'node:util'
2
1
  import { assert } from './assert.js'
3
2
  import { AbsolutePath, assertRelativeChildPath, getAbsoluteParent, isFile, resolveAbsolutePath } from './paths.js'
4
3
  import { mkdir, writeFile } from './utils/asyncfs.js'
@@ -27,7 +26,7 @@ export interface FilesBuilder {
27
26
  merge(...files: Files[]): this
28
27
 
29
28
  /** Write a file and add it to the {@link Files} instance being built */
30
- write(file: string, content: string | Buffer): Promise<AbsolutePath>
29
+ write(file: string, content: string | Uint8Array): Promise<AbsolutePath>
31
30
 
32
31
  /** Build and return a {@link Files} instance */
33
32
  build(): Files
@@ -48,6 +47,13 @@ export class Files {
48
47
  constructor(directory: AbsolutePath) {
49
48
  this._directory = directory
50
49
  this._files = []
50
+
51
+ // Nicety for "console.log" / "util.inspect"...
52
+ const inspect = Symbol.for('nodejs.util.inspect.custom')
53
+ Object.defineProperty(this, inspect, { value: () => ({
54
+ directory: this._directory,
55
+ files: [ ...this._files ],
56
+ }) })
51
57
  }
52
58
 
53
59
  /** Return the _directory_ where this {@link Files} is rooted */
@@ -75,15 +81,6 @@ export class Files {
75
81
  for (const file of this) yield [ file, resolveAbsolutePath(this._directory, file) ]
76
82
  }
77
83
 
78
- /* Nicety for logging */
79
- [inspect.custom](): any {
80
- const self = this
81
- return new class Files {
82
- directory = self._directory
83
- files = [ ...self._files ]
84
- }
85
- }
86
-
87
84
  /** Create a new {@link FilesBuilder} creating {@link Files} instances. */
88
85
  static builder(files: Files): FilesBuilder
89
86
  static builder(directory: AbsolutePath): FilesBuilder
@@ -136,7 +133,7 @@ export class Files {
136
133
  return this
137
134
  },
138
135
 
139
- async write(file: string, content: string | Buffer): Promise<AbsolutePath> {
136
+ async write(file: string, content: string | Uint8Array): Promise<AbsolutePath> {
140
137
  const relative = assertRelativeChildPath(instance.directory, file)
141
138
  const absolute = resolveAbsolutePath(instance.directory, relative)
142
139
  const directory = getAbsoluteParent(absolute)
package/src/paths.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { statSync } from 'node:fs'
2
2
  import { createRequire } from 'node:module'
3
- import { dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path'
3
+ import { dirname, extname, isAbsolute, join, normalize, relative, resolve, sep } from 'node:path'
4
4
  import { fileURLToPath, pathToFileURL } from 'node:url'
5
5
  import { assert } from './assert.js'
6
6
 
@@ -158,7 +158,7 @@ export function commonPath(path: AbsolutePath, ...paths: string[]): AbsolutePath
158
158
  // Here the first path will be split into its components
159
159
  // on win => [ 'C:', 'Windows', 'System32' ]
160
160
  // on unx => [ '', 'usr'
161
- const components = path.split(sep)
161
+ const components = normalize(path).split(sep)
162
162
 
163
163
  let length = components.length
164
164
  for (const current of paths) {
package/src/plugs/copy.ts CHANGED
@@ -1,11 +1,10 @@
1
- import fs from '../utils/asyncfs.js'
2
-
3
1
  import { assert } from '../assert.js'
4
2
  import { Files } from '../files.js'
5
3
  import { $p } from '../log.js'
6
4
  import { assertAbsolutePath, getAbsoluteParent, resolveAbsolutePath } from '../paths.js'
7
5
  import { install, Plug } from '../pipe.js'
8
6
  import { Run } from '../run.js'
7
+ import { chmod, copyFile, fsConstants, mkdir } from '../utils/asyncfs.js'
9
8
 
10
9
  /** Options for copying files */
11
10
  export interface CopyOptions {
@@ -30,7 +29,7 @@ export class Copy implements Plug<Files> {
30
29
  async pipe(files: Files, run: Run): Promise<Files> {
31
30
  /* Destructure our options with some defaults and compute write flags */
32
31
  const { mode, dirMode, overwrite, rename = (s): string => s } = this._options
33
- const flags = overwrite ? fs.constants.COPYFILE_EXCL : 0
32
+ const flags = overwrite ? fsConstants.COPYFILE_EXCL : 0
34
33
  const dmode = parseMode(dirMode)
35
34
  const fmode = parseMode(mode)
36
35
 
@@ -51,26 +50,26 @@ export class Copy implements Plug<Files> {
51
50
 
52
51
  /* Create the parent directory, recursively */
53
52
  const directory = getAbsoluteParent(target)
54
- const firstParent = await fs.mkdir(directory, { recursive: true })
53
+ const firstParent = await mkdir(directory, { recursive: true })
55
54
 
56
55
  /* Set the mode for all created directories */
57
56
  if (firstParent && (dmode !== undefined)) {
58
57
  assertAbsolutePath(firstParent)
59
58
  for (let dir = directory; ; dir = getAbsoluteParent(dir)) {
60
59
  run.log.trace(`Setting mode ${stringifyMode(dmode)} for directory`, $p(dir))
61
- await fs.chmod(dir, dmode)
60
+ await chmod(dir, dmode)
62
61
  if (dir === firstParent) break
63
62
  }
64
63
  }
65
64
 
66
65
  /* Actually _copy_ the file */
67
66
  run.log.trace(`Copying "${$p(absolute)}" to "${$p(target)}"`)
68
- await fs.copyFile(absolute, target, flags)
67
+ await copyFile(absolute, target, flags)
69
68
 
70
69
  /* Set the mode, if we need to */
71
70
  if (fmode !== undefined) {
72
71
  run.log.trace(`Setting mode ${stringifyMode(fmode)} for file`, $p(target))
73
- await fs.chmod(target, fmode)
72
+ await chmod(target, fmode)
74
73
  }
75
74
 
76
75
  /* Record this file */
@@ -129,7 +129,6 @@ declare module '../pipe.js' {
129
129
  * ========================================================================== */
130
130
 
131
131
  export * from './esbuild/bundle-locals.js'
132
- export * from './esbuild/check-dependencies.js'
133
132
  export * from './esbuild/fix-extensions.js'
134
133
 
135
134
  /* ========================================================================== *
package/src/run.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { join } from 'node:path'
1
+ import { join, normalize, sep } from 'node:path'
2
2
  import { assert } from './assert.js'
3
3
  import { Files, FilesBuilder } from './files.js'
4
4
  import { createReport, getLevelNumber, getLogger, Logger, LogLevelString, Report } from './log.js'
@@ -114,8 +114,9 @@ export class RunImpl implements Run {
114
114
  if (! path) return this.buildDir
115
115
 
116
116
  if (path.startsWith('@')) {
117
- const relative = path.substring(1)
118
- assert(! isAbsolutePath(relative), `Path component of "${path}" is absolute`)
117
+ const components = normalize(path.substring(1)).split(sep)
118
+ const relative = join(...components) // this will remove any leading slash
119
+ assert(! isAbsolutePath(relative), `Path "${path.substring(1)}" is absolute`)
119
120
  return resolveAbsolutePath(this.buildDir, relative)
120
121
  }
121
122
 
@@ -1,6 +1,12 @@
1
1
  import { constants } from 'node:fs'
2
2
  import fsp from 'node:fs/promises'
3
3
 
4
+ type FsPromises = typeof fsp
5
+
6
+ type FsWrappers = {
7
+ [ K in keyof FsPromises as FsPromises[K] extends ((...args: any[]) => any) ? K : never ]: FsPromises[K]
8
+ }
9
+
4
10
  /*
5
11
  * I have no idea why sometimes stacks don't have a trace when coming out of
6
12
  * the "node:fs/promises" api... There is a _stack_ property on the object
@@ -35,17 +41,12 @@ const fs = Object.entries(fsp as any).reduce((fs, [ key, val ]) => {
35
41
  Object.defineProperty(f, 'name', { value: key })
36
42
  /* Assign the wrapper to our exports */
37
43
  fs[key] = f
38
- } else {
39
- /* Not a function, no wrapping... */
40
- fs[key] = val
41
44
  }
42
45
 
43
46
  /* Return the "reduced" exports */
44
47
  return fs
45
- }, { constants } as any) as typeof fsp & { constants: typeof constants }
48
+ }, {} as any) as FsWrappers
46
49
 
47
- /* Export _our_ version of the "node:fs/promises" module */
48
- export default fs
49
50
 
50
51
  /* Export all the wrappers to "node:fs/promises" individually */
51
52
  export const access = fs.access
@@ -78,5 +79,5 @@ export const appendFile = fs.appendFile
78
79
  export const readFile = fs.readFile
79
80
  export const watch = fs.watch
80
81
 
81
- /* Export constants from "node:/fs" in addition */
82
- export { constants } from 'node:fs'
82
+ /* Export constants from "node:fs" */
83
+ export const fsConstants = constants
package/src/utils/walk.ts CHANGED
@@ -1,7 +1,8 @@
1
+ import { Dir } from 'node:fs'
1
2
  import { basename, join } from 'node:path'
2
3
  import { $p, log } from '../log.js'
3
4
  import { AbsolutePath, resolveAbsolutePath } from '../paths.js'
4
- import { readdir, stat } from './asyncfs.js'
5
+ import { opendir, stat } from './asyncfs.js'
5
6
  import { match, MatchOptions } from './match.js'
6
7
 
7
8
  /** Specific options for walking a directory */
@@ -101,14 +102,18 @@ async function* walker(args: WalkerArguments): AsyncGenerator<string, void, void
101
102
  const dir = resolveAbsolutePath(directory, relative)
102
103
  if (! onDirectory(dir)) return
103
104
  log.trace('Reading directory', $p(dir))
104
- const dirents = await readdir(dir, { withFileTypes: true }).catch((error) => {
105
+
106
+ let dirents: Dir
107
+ try {
108
+ dirents = await opendir(dir)
109
+ } catch (error: any) {
105
110
  if (error.code !== 'ENOENT') throw error
106
111
  log.warn('Directory', $p(dir), 'not found')
107
- return []
108
- })
112
+ return
113
+ }
109
114
 
110
115
  /* For each entry we determine the full path */
111
- for (const dirent of dirents) {
116
+ for await (const dirent of dirents) {
112
117
  const path = join(relative, dirent.name)
113
118
 
114
119
  /* If the entry is a file and matches, yield it */
package/types/files.d.ts CHANGED
@@ -1,6 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { inspect } from 'node:util';
4
1
  import { AbsolutePath } from './paths.js';
5
2
  /** The {@link FilesBuilder} interface defines a builder for {@link Files}. */
6
3
  export interface FilesBuilder {
@@ -22,7 +19,7 @@ export interface FilesBuilder {
22
19
  /** Merge orther {@link Files} instance to the {@link Files} being built */
23
20
  merge(...files: Files[]): this;
24
21
  /** Write a file and add it to the {@link Files} instance being built */
25
- write(file: string, content: string | Buffer): Promise<AbsolutePath>;
22
+ write(file: string, content: string | Uint8Array): Promise<AbsolutePath>;
26
23
  /** Build and return a {@link Files} instance */
27
24
  build(): Files;
28
25
  }
@@ -48,7 +45,6 @@ export declare class Files {
48
45
  absolutePaths(): Generator<AbsolutePath>;
49
46
  /** Return an iterator over all _relative_ to _absolute_ mappings */
50
47
  pathMappings(): Generator<[relative: string, absolute: AbsolutePath]>;
51
- [inspect.custom](): any;
52
48
  /** Create a new {@link FilesBuilder} creating {@link Files} instances. */
53
49
  static builder(files: Files): FilesBuilder;
54
50
  static builder(directory: AbsolutePath): FilesBuilder;
@@ -20,5 +20,4 @@ declare module '../pipe.js' {
20
20
  }
21
21
  }
22
22
  export * from './esbuild/bundle-locals.js';
23
- export * from './esbuild/check-dependencies.js';
24
23
  export * from './esbuild/fix-extensions.js';
@@ -1,10 +1,7 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { constants } from 'node:fs';
3
4
  import fsp from 'node:fs/promises';
4
- declare const fs: typeof fsp & {
5
- constants: typeof constants;
6
- };
7
- export default fs;
8
5
  export declare const access: typeof fsp.access;
9
6
  export declare const copyFile: typeof fsp.copyFile;
10
7
  export declare const cp: typeof fsp.cp;
@@ -34,4 +31,4 @@ export declare const writeFile: typeof fsp.writeFile;
34
31
  export declare const appendFile: typeof fsp.appendFile;
35
32
  export declare const readFile: typeof fsp.readFile;
36
33
  export declare const watch: typeof fsp.watch;
37
- export { constants } from 'node:fs';
34
+ export declare const fsConstants: typeof constants;
@@ -1,140 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // plugs/esbuild/check-dependencies.ts
21
- var check_dependencies_exports = {};
22
- __export(check_dependencies_exports, {
23
- checkDependencies: () => checkDependencies
24
- });
25
- module.exports = __toCommonJS(check_dependencies_exports);
26
- var import_async = require("../../async.cjs");
27
- var import_log = require("../../log.cjs");
28
- var import_asyncfs = require("../../utils/asyncfs.cjs");
29
- var import_options = require("../../utils/options.cjs");
30
- function checkDependencies(...args) {
31
- const run = (0, import_async.currentRun)();
32
- const { params, options } = (0, import_options.parseOptions)(args, {
33
- ignored: [],
34
- allowDev: false,
35
- allowPeer: true,
36
- allowOptional: true,
37
- allowUnused: false
38
- });
39
- const allowDev = convertOption(options.allowDev);
40
- const allowPeer = convertOption(options.allowPeer);
41
- const allowOptional = convertOption(options.allowOptional);
42
- const allowUnused = convertOption(options.allowUnused);
43
- const dependencies = [];
44
- const devDependencies = [];
45
- const peerDependencies = [];
46
- const optionalDependencies = [];
47
- const ignored = new Set(options.ignored);
48
- const used = /* @__PURE__ */ new Set();
49
- return {
50
- name: "check-dependencies",
51
- setup(build) {
52
- build.initialOptions.bundle = true;
53
- let packageJson;
54
- build.onStart(async () => {
55
- if (!run)
56
- return { errors: [{ text: "Unable to find current Run" }] };
57
- const resolved = run.resolve(params[0] || "@package.json");
58
- packageJson = resolved;
59
- try {
60
- const data = await (0, import_asyncfs.readFile)(resolved, "utf-8");
61
- const json = JSON.parse(data);
62
- dependencies.push(...dependencyKeys(json.dependencies));
63
- devDependencies.push(...dependencyKeys(json.devDependencies));
64
- peerDependencies.push(...dependencyKeys(json.peerDependencies));
65
- optionalDependencies.push(...dependencyKeys(json.optionalDependencies));
66
- } catch (error) {
67
- return { errors: [{ text: `Unable to parse ${(0, import_log.$p)(resolved)}` }] };
68
- }
69
- });
70
- build.onResolve({ filter: /.*/ }, (args2) => {
71
- if (args2.importer.match(/\/node_modules\//))
72
- return;
73
- if (args2.path.startsWith("node:"))
74
- return;
75
- if (args2.path.startsWith("."))
76
- return;
77
- if (dependencies.includes(args2.path)) {
78
- used.add(args2.path);
79
- return { external: true };
80
- }
81
- const [result, label] = optionalDependencies.includes(args2.path) ? [allowOptional, "an optional"] : peerDependencies.includes(args2.path) ? [allowPeer, "a peer"] : devDependencies.includes(args2.path) ? [allowDev, "a dev"] : ["error", void 0];
82
- if (ignored.has(args2.path))
83
- return { external: true };
84
- if (result === "ignore")
85
- return { external: true };
86
- const text = label ? `Dependency "${args2.path}" is ${label} dependency` : `Dependency "${args2.path}" not specified in "package.json"`;
87
- return result === "warn" ? { external: true, warnings: [{ text }] } : { external: true, errors: [{ text }] };
88
- });
89
- build.onEnd((result) => {
90
- if (allowUnused === "ignore")
91
- return;
92
- const unused = new Set(dependencies);
93
- ignored.forEach((dep) => unused.delete(dep));
94
- used.forEach((dep) => unused.delete(dep));
95
- const messages = [...unused].map((dep) => `Unused dependency "${dep}"`).map((text) => ({
96
- id: "",
97
- pluginName: "check-dependencies",
98
- location: {
99
- file: packageJson,
100
- namespace: "file",
101
- line: 0,
102
- column: 0,
103
- length: 0,
104
- lineText: "",
105
- suggestion: ""
106
- },
107
- text,
108
- notes: [],
109
- detail: void 0
110
- }));
111
- if (allowUnused === "warn") {
112
- result.warnings.push(...messages);
113
- } else {
114
- result.errors.push(...messages);
115
- }
116
- });
117
- }
118
- };
119
- }
120
- function convertOption(option) {
121
- if (option === "warn")
122
- return "warn";
123
- if (option === "error")
124
- return "error";
125
- if (option)
126
- return "ignore";
127
- return "error";
128
- }
129
- function dependencyKeys(dependencies) {
130
- if (!dependencies)
131
- return [];
132
- if (typeof dependencies !== "object")
133
- return [];
134
- return Object.keys(dependencies).filter((key) => typeof key === "string");
135
- }
136
- // Annotate the CommonJS export names for ESM import in node:
137
- 0 && (module.exports = {
138
- checkDependencies
139
- });
140
- //# sourceMappingURL=check-dependencies.cjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugs/esbuild/check-dependencies.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA2B;AAC3B,iBAAmB;AAEnB,qBAAyB;AACzB,qBAA2C;AAepC,SAAS,qBAAqB,MAAsD;AACzF,QAAM,UAAM,yBAAW;AAEvB,QAAM,EAAE,QAAQ,QAAQ,QAAI,6BAAa,MAAM;AAAA,IAC7C,SAAS,CAAC;AAAA,IACV,UAAU;AAAA,IACV,WAAW;AAAA,IACX,eAAe;AAAA,IACf,aAAa;AAAA,EACf,CAAC;AAED,QAAM,WAAW,cAAc,QAAQ,QAAQ;AAC/C,QAAM,YAAY,cAAc,QAAQ,SAAS;AACjD,QAAM,gBAAgB,cAAc,QAAQ,aAAa;AACzD,QAAM,cAAc,cAAc,QAAQ,WAAW;AAErD,QAAM,eAAyB,CAAC;AAChC,QAAM,kBAA4B,CAAC;AACnC,QAAM,mBAA6B,CAAC;AACpC,QAAM,uBAAiC,CAAC;AACxC,QAAM,UAAU,IAAI,IAAI,QAAQ,OAAO;AACvC,QAAM,OAAO,oBAAI,IAAY;AA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A,SAAS,eAAe,cAA6B;AACnD,MAAI,CAAE;AAAc,WAAO,CAAC;AAC5B,MAAI,OAAO,iBAAiB;AAAU,WAAO,CAAC;AAC9C,SAAO,OAAO,KAAK,YAAY,EAAE,OAAO,CAAC,QAAQ,OAAO,QAAQ,QAAQ;AAC1E;",
5
- "names": ["args"]
6
- }
@@ -1,115 +0,0 @@
1
- // plugs/esbuild/check-dependencies.ts
2
- import { currentRun } from "../../async.mjs";
3
- import { $p } from "../../log.mjs";
4
- import { readFile } from "../../utils/asyncfs.mjs";
5
- import { parseOptions } from "../../utils/options.mjs";
6
- function checkDependencies(...args) {
7
- const run = currentRun();
8
- const { params, options } = parseOptions(args, {
9
- ignored: [],
10
- allowDev: false,
11
- allowPeer: true,
12
- allowOptional: true,
13
- allowUnused: false
14
- });
15
- const allowDev = convertOption(options.allowDev);
16
- const allowPeer = convertOption(options.allowPeer);
17
- const allowOptional = convertOption(options.allowOptional);
18
- const allowUnused = convertOption(options.allowUnused);
19
- const dependencies = [];
20
- const devDependencies = [];
21
- const peerDependencies = [];
22
- const optionalDependencies = [];
23
- const ignored = new Set(options.ignored);
24
- const used = /* @__PURE__ */ new Set();
25
- return {
26
- name: "check-dependencies",
27
- setup(build) {
28
- build.initialOptions.bundle = true;
29
- let packageJson;
30
- build.onStart(async () => {
31
- if (!run)
32
- return { errors: [{ text: "Unable to find current Run" }] };
33
- const resolved = run.resolve(params[0] || "@package.json");
34
- packageJson = resolved;
35
- try {
36
- const data = await readFile(resolved, "utf-8");
37
- const json = JSON.parse(data);
38
- dependencies.push(...dependencyKeys(json.dependencies));
39
- devDependencies.push(...dependencyKeys(json.devDependencies));
40
- peerDependencies.push(...dependencyKeys(json.peerDependencies));
41
- optionalDependencies.push(...dependencyKeys(json.optionalDependencies));
42
- } catch (error) {
43
- return { errors: [{ text: `Unable to parse ${$p(resolved)}` }] };
44
- }
45
- });
46
- build.onResolve({ filter: /.*/ }, (args2) => {
47
- if (args2.importer.match(/\/node_modules\//))
48
- return;
49
- if (args2.path.startsWith("node:"))
50
- return;
51
- if (args2.path.startsWith("."))
52
- return;
53
- if (dependencies.includes(args2.path)) {
54
- used.add(args2.path);
55
- return { external: true };
56
- }
57
- const [result, label] = optionalDependencies.includes(args2.path) ? [allowOptional, "an optional"] : peerDependencies.includes(args2.path) ? [allowPeer, "a peer"] : devDependencies.includes(args2.path) ? [allowDev, "a dev"] : ["error", void 0];
58
- if (ignored.has(args2.path))
59
- return { external: true };
60
- if (result === "ignore")
61
- return { external: true };
62
- const text = label ? `Dependency "${args2.path}" is ${label} dependency` : `Dependency "${args2.path}" not specified in "package.json"`;
63
- return result === "warn" ? { external: true, warnings: [{ text }] } : { external: true, errors: [{ text }] };
64
- });
65
- build.onEnd((result) => {
66
- if (allowUnused === "ignore")
67
- return;
68
- const unused = new Set(dependencies);
69
- ignored.forEach((dep) => unused.delete(dep));
70
- used.forEach((dep) => unused.delete(dep));
71
- const messages = [...unused].map((dep) => `Unused dependency "${dep}"`).map((text) => ({
72
- id: "",
73
- pluginName: "check-dependencies",
74
- location: {
75
- file: packageJson,
76
- namespace: "file",
77
- line: 0,
78
- column: 0,
79
- length: 0,
80
- lineText: "",
81
- suggestion: ""
82
- },
83
- text,
84
- notes: [],
85
- detail: void 0
86
- }));
87
- if (allowUnused === "warn") {
88
- result.warnings.push(...messages);
89
- } else {
90
- result.errors.push(...messages);
91
- }
92
- });
93
- }
94
- };
95
- }
96
- function convertOption(option) {
97
- if (option === "warn")
98
- return "warn";
99
- if (option === "error")
100
- return "error";
101
- if (option)
102
- return "ignore";
103
- return "error";
104
- }
105
- function dependencyKeys(dependencies) {
106
- if (!dependencies)
107
- return [];
108
- if (typeof dependencies !== "object")
109
- return [];
110
- return Object.keys(dependencies).filter((key) => typeof key === "string");
111
- }
112
- export {
113
- checkDependencies
114
- };
115
- //# sourceMappingURL=check-dependencies.mjs.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugs/esbuild/check-dependencies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