@checkdigit/typescript-config 3.3.0-PR.30-2491 → 3.3.0-PR.30-0e8f

Sign up to get free protection for your applications and to get access to all the features.
package/bin/builder.mjs CHANGED
@@ -1,20 +1,13 @@
1
- #!/usr/bin/env node
1
+ // src/builder/index.mts
2
+ import { strict as assert2 } from "node:assert";
3
+ import { parseArgs } from "node:util";
2
4
 
3
- import { promises as fs } from 'node:fs';
4
- import path from 'node:path';
5
- import url from 'node:url';
6
- import { parseArgs } from 'node:util';
7
-
8
- // eslint-disable-next-line import/no-extraneous-dependencies
9
- import { build } from 'esbuild';
10
- // eslint-disable-next-line import/no-extraneous-dependencies
11
- import typescript from 'typescript';
12
-
13
- /**
14
- * Recursively obtains all files in a directory
15
- * @param {string} directory
16
- * @returns {Promise<string[]>}
17
- */
5
+ // src/builder/builder.mts
6
+ import { strict as assert } from "node:assert";
7
+ import { promises as fs } from "node:fs";
8
+ import path from "node:path";
9
+ import typescript from "typescript";
10
+ import { build } from "esbuild";
18
11
  async function getFiles(directory) {
19
12
  const entries = await fs.readdir(directory, { withFileTypes: true });
20
13
  const files = await Promise.all(
@@ -25,89 +18,80 @@ async function getFiles(directory) {
25
18
  );
26
19
  return files.flat();
27
20
  }
28
-
29
- /**
30
- * @param {import('esbuild').PluginBuild} pluginBuild
31
- */
32
21
  function setup(pluginBuild) {
33
22
  pluginBuild.onResolve({ filter: /.*/u }, async (resolved) => {
34
- if (resolved.kind === 'entry-point' || !resolved.path.startsWith('.') || resolved.path.endsWith('.js')) {
35
- return { external: resolved.kind !== 'entry-point' };
23
+ if (resolved.kind === "entry-point" || !resolved.path.startsWith(".") || resolved.path.endsWith(".js")) {
24
+ return { external: resolved.kind !== "entry-point" };
36
25
  }
37
26
  let isDirectory = false;
38
27
  try {
39
28
  const stats = await fs.lstat(path.join(resolved.resolveDir, resolved.path));
40
29
  isDirectory = stats.isDirectory();
41
30
  } catch {
42
- // do nothing
43
31
  }
44
32
  let newPath = resolved.path;
45
33
  newPath += isDirectory ? `/index.mjs` : `.mjs`;
46
34
  return { path: newPath, external: true };
47
35
  });
48
36
  }
37
+ async function builder_default(inDir2, outDir2) {
38
+ const sourceDirectory = path.join(process.cwd(), inDir2);
39
+ const allSourceFiles = await getFiles(sourceDirectory);
40
+ const productionSourceFiles = allSourceFiles.filter(
41
+ // && !file.endsWith('.test.ts') && !file.endsWith('.spec.ts')
42
+ (file) => file.endsWith(".ts")
43
+ );
44
+ const configFile = typescript.readConfigFile("./tsconfig.json", typescript.sys.readFile);
45
+ const compilerOptions = typescript.parseJsonConfigFileContent(configFile.config, typescript.sys, "./");
46
+ const program = typescript.createProgram(productionSourceFiles, {
47
+ ...compilerOptions.options,
48
+ noEmitOnError: true,
49
+ emitDeclarationOnly: true,
50
+ rootDir: inDir2,
51
+ outDir: outDir2
52
+ });
53
+ const emitResult = program.emit();
54
+ const allDiagnostics = [...typescript.getPreEmitDiagnostics(program), ...emitResult.diagnostics];
55
+ for (const diagnostic of allDiagnostics) {
56
+ if (diagnostic.file) {
57
+ assert.ok(diagnostic.start !== void 0);
58
+ const { line, character } = typescript.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
59
+ const message = typescript.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
60
+ console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
61
+ } else {
62
+ console.log(typescript.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
63
+ }
64
+ }
65
+ if (emitResult.emitSkipped) {
66
+ throw new Error("TypeScript compilation failed");
67
+ }
68
+ await build({
69
+ entryPoints: productionSourceFiles,
70
+ bundle: true,
71
+ platform: "node",
72
+ format: "esm",
73
+ outdir: outDir2,
74
+ sourcemap: "inline",
75
+ sourcesContent: false,
76
+ outExtension: { ".js": ".mjs" },
77
+ plugins: [
78
+ {
79
+ name: "resolve-ts",
80
+ setup
81
+ }
82
+ ]
83
+ });
84
+ }
49
85
 
50
- const {
51
- values: { inDir, outDir },
86
+ // src/builder/index.mts
87
+ var {
88
+ values: { inDir, outDir }
52
89
  } = parseArgs({
53
90
  options: {
54
- inDir: { type: 'string', short: 'i', default: 'src' },
55
- outDir: { type: 'string', short: 'o', default: 'build' },
56
- },
57
- });
58
-
59
- /**
60
- * Emit declarations using typescript compiler
61
- */
62
- const sourceDirectory = path.join(process.cwd(), inDir);
63
- const allSourceFiles = await getFiles(sourceDirectory);
64
- const productionSourceFiles = allSourceFiles.filter(
65
- (file) => file.endsWith('.ts') // && !file.endsWith('.test.ts') && !file.endsWith('.spec.ts')
66
- );
67
-
68
- const configFile = typescript.readConfigFile('./tsconfig.json', typescript.sys.readFile);
69
- const compilerOptions = typescript.parseJsonConfigFileContent(configFile.config, typescript.sys, './');
70
-
71
- const program = typescript.createProgram(productionSourceFiles, {
72
- ...compilerOptions.options,
73
- noEmitOnError: true,
74
- emitDeclarationOnly: true,
75
- rootDir: inDir,
76
- outDir,
77
- });
78
- const emitResult = program.emit();
79
- const allDiagnostics = [...typescript.getPreEmitDiagnostics(program), ...emitResult.diagnostics];
80
- for (const diagnostic of allDiagnostics) {
81
- if (diagnostic.file) {
82
- const { line, character } = typescript.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
83
- const message = typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
84
- // eslint-disable-next-line no-console
85
- console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
86
- } else {
87
- // eslint-disable-next-line no-console
88
- console.log(typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\n'));
91
+ inDir: { type: "string", short: "i", default: "src" },
92
+ outDir: { type: "string", short: "o", default: "build" }
89
93
  }
90
- }
91
- if (emitResult.emitSkipped) {
92
- throw new Error('TypeScript compilation failed');
93
- }
94
-
95
- /**
96
- * Emit ESM javascript using esbuild
97
- */
98
- await build({
99
- entryPoints: productionSourceFiles,
100
- bundle: true,
101
- platform: 'node',
102
- format: 'esm',
103
- outdir: outDir,
104
- sourcemap: 'inline',
105
- sourcesContent: false,
106
- outExtension: { '.js': '.mjs' },
107
- plugins: [
108
- {
109
- name: 'resolve-ts',
110
- setup,
111
- },
112
- ],
113
94
  });
95
+ assert2.ok(inDir !== void 0, "inDir is required");
96
+ assert2.ok(outDir !== void 0, "outDir is required");
97
+ await builder_default(inDir, outDir);
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@checkdigit/typescript-config","version":"3.3.0-PR.30-2491","description":"Check Digit standard Typescript configuration","prettier":"@checkdigit/prettier-config","engines":{"node":">=16"},"bin":{"builder":"./bin/builder.mjs"},"peerDependencies":{"@types/node":">=16","typescript":">=5.0.4 <5.1"},"repository":{"type":"git","url":"git+https://github.com/checkdigit/typescript-config.git"},"author":"Check Digit, LLC","license":"MIT","bugs":{"url":"https://github.com/checkdigit/typescript-config/issues"},"homepage":"https://github.com/checkdigit/typescript-config#readme","scripts":{"preversion":"npm test","postversion":"git push && git push --tags","lint:fix":"eslint -f unix --ext .ts,.mts src --fix","lint":"eslint -f unix --ext .ts,.mts src","prettier":"prettier --ignore-path .gitignore --list-different .","prettier:fix":"prettier --ignore-path .gitignore --write .","test":"npm run ci:compile && npm run ci:test && npm run ci:lint && npm run ci:style","build-builder":"tsc --module nodenext --outDir build-builder src/builder/builder.mts","build-tsc-cjs":"rimraf build-tsc-cjs && tsc --outDir build-tsc-cjs","build-esbuild-cjs":"rimraf build-esbuild-cjs && esbuild ./src/*.ts ./src/*/*.ts --platform=node --bundle --format=cjs --sourcemap=inline --sources-content=false --outdir=build-esbuild-cjs","build-esbuild-cjs-bundle":"rimraf build-esbuild-cjs-bundle && esbuild src/test/index.test.ts --bundle --platform=node --format=cjs --sourcemap=inline --sources-content=false --outfile=build-esbuild-cjs-bundle/test/index.test.cjs","build-esbuild-esm":"rimraf build-esbuild-esm && node bin/builder.mjs --outDir=build-esbuild-esm","build-esbuild-esm-bundle":"rimraf build-esbuild-esm-bundle && esbuild src/test/index.test.ts --bundle --platform=node --format=esm --sourcemap=inline --sources-content=false --outfile=build-esbuild-esm-bundle/test/index.test.mjs","test-jest-esm":"NODE_OPTIONS=\"--experimental-vm-modules\" jest --coverage=false src/*.mts src/*/*.mts src/*/*/*.mts","test-jest-cjs":"jest --coverage=false src/*.ts src/*/*.ts src/*/*/*.ts","test-tsc-cjs":"node --test build-tsc-cjs/test/index.test.js","test-esbuild-cjs":"node --test build-esbuild-cjs/test/index.test.js","test-esbuild-cjs-bundle":"node --test build-esbuild-cjs-bundle/test/index.test.cjs","test-esbuild-esm":"node --test build-esbuild-esm/test/index.test.mjs","test-esbuild-esm-bundle":"echo 'node -test build-esbuild-esm-bundle/test/index.test.mjs'","ci:test":"npm run test-jest-cjs && npm run test-jest-esm &&npm run test-tsc-cjs && npm run test-esbuild-cjs && npm run test-esbuild-cjs-bundle && npm run test-esbuild-esm && npm run test-esbuild-esm-bundle","ci:compile":"npm run build-tsc-cjs && npm run build-esbuild-cjs && npm run build-esbuild-cjs-bundle && npm run build-esbuild-esm && npm run build-esbuild-esm-bundle","ci:lint":"npm run lint","ci:style":"npm run prettier"},"devDependencies":{"@checkdigit/prettier-config":"^3.4.0","@types/debug":"^4.1.7","@types/jest":"^29.5.1","@typescript-eslint/eslint-plugin":"^5.59.5","@typescript-eslint/parser":"^5.59.5","debug":"^4.3.4","esbuild":"^0.17.18","eslint":"^8.40.0","eslint-config-prettier":"^8.8.0","get-port":"^6.1.2","got":"^11.8.6","jest":"^29.5.0","rimraf":"^5.0.0","ts-jest":"^29.1.0"},"eslintConfig":{"parser":"@typescript-eslint/parser","plugins":["@typescript-eslint"],"parserOptions":{"project":"./tsconfig.json"},"extends":["eslint:all","plugin:@typescript-eslint/recommended","plugin:@typescript-eslint/recommended-requiring-type-checking","plugin:@typescript-eslint/strict","prettier"],"rules":{"@typescript-eslint/non-nullable-type-assertion-style":"error","capitalized-comments":"off","one-var":"off","sort-keys":"off","func-style":["error","declaration",{"allowArrowFunctions":true}],"no-magic-numbers":["error",{"ignore":[1]}],"no-undefined":"off","no-ternary":"off"},"overrides":[{"files":["*.spec.mts","*.test.mts","*.spec.ts","*.test.ts"],"rules":{"@typescript-eslint/non-nullable-type-assertion-style":"off","@typescript-eslint/ban-types":"off","@typescript-eslint/require-await":"off","@typescript-eslint/consistent-type-definitions":"off","@typescript-eslint/ban-ts-comment":"off","@typescript-eslint/no-unnecessary-condition":"off","@typescript-eslint/consistent-indexed-object-style":"off","@typescript-eslint/no-unused-vars":"off","@typescript-eslint/no-unsafe-member-access":"off","sort-imports":"off","line-comment-position":"off","no-inline-comments":"off","no-param-reassign":"off","id-length":"off","no-magic-numbers":"off","func-names":"off","no-duplicate-imports":"off","symbol-description":"off","no-invalid-this":"off"}}]},"jest":{"moduleFileExtensions":["js","mjs","cjs","ts","mts","json","node"],"extensionsToTreatAsEsm":[".mts"],"transform":{"^.+\\.mts$":["ts-jest",{"isolatedModules":true,"diagnostics":false,"useESM":true}],"^.+\\.ts$":["ts-jest",{"isolatedModules":true,"diagnostics":false,"useESM":false}]},"collectCoverageFrom":["<rootDir>/src/**","!<rootDir>/src/**/*.spec.mts","!<rootDir>/src/**/*.test.mts","!<rootDir>/src/**/*.spec.ts","!<rootDir>/src/**/*.test.ts"],"testMatch":["<rootDir>/src/**/*.spec.ts","<rootDir>/src/**/*.spec.mts"]},"files":["tsconfig.json","SECURITY.md","/src/"]}
1
+ {"name":"@checkdigit/typescript-config","version":"3.3.0-PR.30-0e8f","description":"Check Digit standard Typescript configuration","prettier":"@checkdigit/prettier-config","engines":{"node":">=16"},"bin":{"builder":"./bin/builder.mjs"},"peerDependencies":{"@types/node":">=16","typescript":">=5.0.4 <5.1","esbuild":"0.17.18"},"repository":{"type":"git","url":"git+https://github.com/checkdigit/typescript-config.git"},"author":"Check Digit, LLC","license":"MIT","bugs":{"url":"https://github.com/checkdigit/typescript-config/issues"},"homepage":"https://github.com/checkdigit/typescript-config#readme","scripts":{"preversion":"npm test","postversion":"git push && git push --tags","prepare":"npm run build-builder","lint:fix":"eslint -f unix --ext .ts,.mts src --fix","lint":"eslint -f unix --ext .ts,.mts src","prettier":"prettier --ignore-path .gitignore --list-different .","prettier:fix":"prettier --ignore-path .gitignore --write .","test":"npm run ci:compile && npm run ci:test && npm run ci:lint && npm run ci:style","build-builder":"esbuild src/builder/index.mts --bundle --platform=node --format=esm --external:typescript --external:esbuild --outfile=bin/builder.mjs","build-tsc-cjs":"rimraf build-tsc-cjs && tsc --outDir build-tsc-cjs","build-esbuild-cjs":"rimraf build-esbuild-cjs && esbuild ./src/*.ts ./src/*/*.ts --platform=node --bundle --format=cjs --sourcemap=inline --sources-content=false --outdir=build-esbuild-cjs","build-esbuild-cjs-bundle":"rimraf build-esbuild-cjs-bundle && esbuild src/test/index.test.ts --bundle --platform=node --format=cjs --sourcemap=inline --sources-content=false --outfile=build-esbuild-cjs-bundle/test/index.test.cjs","build-esbuild-esm":"rimraf build-esbuild-esm && node bin/builder.mjs --outDir=build-esbuild-esm","build-esbuild-esm-bundle":"rimraf build-esbuild-esm-bundle && esbuild src/test/index.test.ts --bundle --platform=node --format=esm --sourcemap=inline --sources-content=false --outfile=build-esbuild-esm-bundle/test/index.test.mjs","test-jest-esm":"NODE_OPTIONS=\"--experimental-vm-modules\" jest --coverage=false src/*.mts src/*/*.mts src/*/*/*.mts","test-jest-cjs":"jest --coverage=false src/*.ts src/*/*.ts src/*/*/*.ts","test-tsc-cjs":"node --test build-tsc-cjs/test/index.test.js","test-esbuild-cjs":"node --test build-esbuild-cjs/test/index.test.js","test-esbuild-cjs-bundle":"node --test build-esbuild-cjs-bundle/test/index.test.cjs","test-esbuild-esm":"node --test build-esbuild-esm/test/index.test.mjs","test-esbuild-esm-bundle":"echo 'node -test build-esbuild-esm-bundle/test/index.test.mjs'","ci:test":"npm run test-jest-cjs && npm run test-jest-esm &&npm run test-tsc-cjs && npm run test-esbuild-cjs && npm run test-esbuild-cjs-bundle && npm run test-esbuild-esm && npm run test-esbuild-esm-bundle","ci:compile":"npm run build-tsc-cjs && npm run build-esbuild-cjs && npm run build-esbuild-cjs-bundle && npm run build-esbuild-esm && npm run build-esbuild-esm-bundle","ci:lint":"npm run lint","ci:style":"npm run prettier"},"devDependencies":{"@checkdigit/prettier-config":"^3.4.0","@types/debug":"^4.1.7","@types/jest":"^29.5.1","@typescript-eslint/eslint-plugin":"^5.59.5","@typescript-eslint/parser":"^5.59.5","debug":"^4.3.4","eslint":"^8.40.0","eslint-config-prettier":"^8.8.0","get-port":"^6.1.2","got":"^11.8.6","jest":"^29.5.0","rimraf":"^5.0.0","ts-jest":"^29.1.0"},"eslintConfig":{"parser":"@typescript-eslint/parser","plugins":["@typescript-eslint"],"parserOptions":{"project":"./tsconfig.json"},"extends":["eslint:all","plugin:@typescript-eslint/recommended","plugin:@typescript-eslint/recommended-requiring-type-checking","plugin:@typescript-eslint/strict","prettier"],"rules":{"@typescript-eslint/non-nullable-type-assertion-style":"error","capitalized-comments":"off","one-var":"off","sort-keys":"off","sort-imports":"off","func-style":["error","declaration",{"allowArrowFunctions":true}],"no-magic-numbers":["error",{"ignore":[1]}],"no-undefined":"off","no-ternary":"off"},"overrides":[{"files":["*.spec.mts","*.test.mts","*.spec.ts","*.test.ts"],"rules":{"@typescript-eslint/non-nullable-type-assertion-style":"off","@typescript-eslint/ban-types":"off","@typescript-eslint/require-await":"off","@typescript-eslint/consistent-type-definitions":"off","@typescript-eslint/ban-ts-comment":"off","@typescript-eslint/no-unnecessary-condition":"off","@typescript-eslint/consistent-indexed-object-style":"off","@typescript-eslint/no-unused-vars":"off","@typescript-eslint/no-unsafe-member-access":"off","line-comment-position":"off","no-inline-comments":"off","no-param-reassign":"off","id-length":"off","no-magic-numbers":"off","func-names":"off","no-duplicate-imports":"off","symbol-description":"off","no-invalid-this":"off"}}]},"jest":{"moduleFileExtensions":["js","mjs","cjs","ts","mts","json","node"],"extensionsToTreatAsEsm":[".mts"],"transform":{"^.+\\.mts$":["ts-jest",{"isolatedModules":true,"diagnostics":false,"useESM":true}],"^.+\\.ts$":["ts-jest",{"isolatedModules":true,"diagnostics":false,"useESM":false}]},"collectCoverageFrom":["<rootDir>/src/**","!<rootDir>/src/**/*.spec.mts","!<rootDir>/src/**/*.test.mts","!<rootDir>/src/**/*.spec.ts","!<rootDir>/src/**/*.test.ts"],"testMatch":["<rootDir>/src/**/*.spec.ts","<rootDir>/src/**/*.spec.mts"]},"files":["tsconfig.json","SECURITY.md","/src/"]}
@@ -4,13 +4,8 @@ import { strict as assert } from 'node:assert';
4
4
  import { promises as fs } from 'node:fs';
5
5
  import path from 'node:path';
6
6
  import typescript from 'typescript';
7
- import url from 'node:url';
8
- // import { parseArgs } from 'node:util';
9
7
 
10
- /*
11
- * import { PluginBuild } from 'esbuild';
12
- * import { build, PluginBuild } from 'esbuild';
13
- */
8
+ import { PluginBuild, build } from 'esbuild';
14
9
 
15
10
  /**
16
11
  * Recursively obtains all files in a directory
@@ -28,30 +23,30 @@ async function getFiles(directory: string): Promise<string[]> {
28
23
  return files.flat();
29
24
  }
30
25
 
31
- // function setup(pluginBuild: PluginBuild) {
32
- // pluginBuild.onResolve({ filter: /.*/u }, async (resolved) => {
33
- // if (resolved.kind === 'entry-point' || !resolved.path.startsWith('.') || resolved.path.endsWith('.js')) {
34
- // return { external: resolved.kind !== 'entry-point' };
35
- // }
36
- // let isDirectory = false;
37
- // try {
38
- // const stats = await fs.lstat(path.join(resolved.resolveDir, resolved.path));
39
- // isDirectory = stats.isDirectory();
40
- // } catch {
41
- // // do nothing
42
- // }
43
- // let newPath = resolved.path;
44
- // newPath += isDirectory ? `/index.mjs` : `.mjs`;
45
- // return { path: newPath, external: true };
46
- // });
47
- // }
26
+ function setup(pluginBuild: PluginBuild) {
27
+ pluginBuild.onResolve({ filter: /.*/u }, async (resolved) => {
28
+ if (resolved.kind === 'entry-point' || !resolved.path.startsWith('.') || resolved.path.endsWith('.js')) {
29
+ return { external: resolved.kind !== 'entry-point' };
30
+ }
31
+ let isDirectory = false;
32
+ try {
33
+ const stats = await fs.lstat(path.join(resolved.resolveDir, resolved.path));
34
+ isDirectory = stats.isDirectory();
35
+ } catch {
36
+ // do nothing
37
+ }
38
+ let newPath = resolved.path;
39
+ newPath += isDirectory ? `/index.mjs` : `.mjs`;
40
+ return { path: newPath, external: true };
41
+ });
42
+ }
48
43
 
49
44
  // eslint-disable-next-line func-names,max-lines-per-function,max-statements
50
45
  export default async function (inDir: string, outDir: string): Promise<void> {
51
46
  /**
52
47
  * Emit declarations using typescript compiler
53
48
  */
54
- const sourceDirectory = path.join(path.dirname(url.fileURLToPath(import.meta.url)), inDir);
49
+ const sourceDirectory = path.join(process.cwd(), inDir);
55
50
  const allSourceFiles = await getFiles(sourceDirectory);
56
51
  const productionSourceFiles = allSourceFiles.filter(
57
52
  // && !file.endsWith('.test.ts') && !file.endsWith('.spec.ts')
@@ -83,27 +78,27 @@ export default async function (inDir: string, outDir: string): Promise<void> {
83
78
  console.log(typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\n'));
84
79
  }
85
80
  }
86
- // if (emitResult.emitSkipped) {
87
- // throw new Error('TypeScript compilation failed');
88
- // }
89
- //
90
- // /**
91
- // * Emit ESM javascript using esbuild
92
- // */
93
- // await build({
94
- // entryPoints: productionSourceFiles,
95
- // bundle: true,
96
- // platform: 'node',
97
- // format: 'esm',
98
- // outdir: outDir as string,
99
- // sourcemap: 'inline',
100
- // sourcesContent: false,
101
- // outExtension: { '.js': '.mjs' },
102
- // plugins: [
103
- // {
104
- // name: 'resolve-ts',
105
- // setup,
106
- // },
107
- // ],
108
- // });
81
+ if (emitResult.emitSkipped) {
82
+ throw new Error('TypeScript compilation failed');
83
+ }
84
+
85
+ /**
86
+ * Emit ESM javascript using esbuild
87
+ */
88
+ await build({
89
+ entryPoints: productionSourceFiles,
90
+ bundle: true,
91
+ platform: 'node',
92
+ format: 'esm',
93
+ outdir: outDir,
94
+ sourcemap: 'inline',
95
+ sourcesContent: false,
96
+ outExtension: { '.js': '.mjs' },
97
+ plugins: [
98
+ {
99
+ name: 'resolve-ts',
100
+ setup,
101
+ },
102
+ ],
103
+ });
109
104
  }
@@ -1,12 +1,12 @@
1
1
  // builder/builder.spec.mts
2
2
 
3
+ import { strict as assert } from 'node:assert';
4
+
3
5
  // @ts-expect-error
4
- import builder from './builder';
6
+ import builder from './builder.mts';
5
7
 
6
8
  describe('test builder', () => {
7
9
  it('should build', async () => {
8
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call
9
- await builder('../test/lib', 'hello');
10
- expect(true).toBe(true);
10
+ await assert.rejects(builder('../test/lib', 'hello'));
11
11
  });
12
12
  });
@@ -1,11 +1,11 @@
1
1
  // builder/index.mts
2
2
 
3
+ import { strict as assert } from 'node:assert';
3
4
  import { parseArgs } from 'node:util';
4
5
 
5
6
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
6
7
  // @ts-expect-error
7
- // eslint-disable-next-line sort-imports
8
- import builder from './builder';
8
+ import builder from './builder.mts';
9
9
 
10
10
  const {
11
11
  values: { inDir, outDir },
@@ -16,5 +16,7 @@ const {
16
16
  },
17
17
  });
18
18
 
19
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/non-nullable-type-assertion-style
20
- await builder(inDir as string, outDir as string);
19
+ assert.ok(inDir !== undefined, 'inDir is required');
20
+ assert.ok(outDir !== undefined, 'outDir is required');
21
+
22
+ await builder(inDir, outDir);