@knighted/duel 2.0.0-rc.1 → 2.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/README.md CHANGED
@@ -24,7 +24,7 @@ Tool for building a Node.js [dual package](https://nodejs.org/api/packages.html#
24
24
  First, install this package to create the `duel` executable inside your `node_modules/.bin` directory.
25
25
 
26
26
  ```console
27
- user@comp ~ $ npm i @knighted/duel --save-dev
27
+ npm i @knighted/duel --save-dev
28
28
  ```
29
29
 
30
30
  Then, given a `package.json` that defines `"type": "module"` and a `tsconfig.json` file that looks something like the following:
@@ -51,7 +51,7 @@ You can create an ES module build for the project defined by the above configura
51
51
  And then running it:
52
52
 
53
53
  ```console
54
- user@comp ~ $ npm run build
54
+ npm run build
55
55
  ```
56
56
 
57
57
  If everything worked, you should have an ESM build inside of `dist` and a CJS build inside of `dist/cjs`. Now you can update your [`exports`](https://nodejs.org/api/packages.html#exports) to match the build output.
package/dist/cjs/duel.cjs CHANGED
@@ -38,7 +38,7 @@ const duel = async (args) => {
38
38
  const runBuild = (project, outDir) => {
39
39
  return new Promise((resolve, reject) => {
40
40
  const args = outDir ? ['-p', project, '--outDir', outDir] : ['-p', project];
41
- const build = (0, node_child_process_1.spawn)(tsc, args, { stdio: 'inherit' });
41
+ const build = (0, node_child_process_1.spawn)(tsc, args, { stdio: 'inherit', shell: node_process_1.platform === 'win32' });
42
42
  build.on('error', err => {
43
43
  reject(new Error(`Failed to compile: ${err.message}`));
44
44
  });
@@ -1,7 +1,7 @@
1
1
  export function init(args: any): Promise<false | {
2
2
  pkg: import("read-package-up", { with: { "resolution-mode": "import" } }).NormalizedReadResult;
3
- dirs: boolean | undefined;
4
- modules: boolean | undefined;
3
+ dirs: boolean;
4
+ modules: boolean;
5
5
  tsconfig: any;
6
6
  projectDir: string;
7
7
  configPath: string;
package/dist/cjs/util.cjs CHANGED
@@ -5,6 +5,7 @@ const node_url_1 = require("node:url");
5
5
  const promises_1 = require("node:fs/promises");
6
6
  const node_child_process_1 = require("node:child_process");
7
7
  const node_process_1 = require("node:process");
8
+ const node_os_1 = require("node:os");
8
9
  const log = (color = '\x1b[30m', msg = '') => {
9
10
  // eslint-disable-next-line no-console
10
11
  console.log(`${color}%s\x1b[0m`, msg);
@@ -19,11 +20,14 @@ const getRealPathAsFileUrl = async (path) => {
19
20
  };
20
21
  exports.getRealPathAsFileUrl = getRealPathAsFileUrl;
21
22
  const getCompileFiles = (tscBinPath, wd = (0, node_process_1.cwd)()) => {
22
- const { stdout } = (0, node_child_process_1.spawnSync)(tscBinPath, ['--listFilesOnly'], { cwd: wd });
23
+ const { stdout } = (0, node_child_process_1.spawnSync)(tscBinPath, ['--listFilesOnly'], {
24
+ cwd: wd,
25
+ shell: node_process_1.platform === 'win32',
26
+ });
23
27
  // Exclude node_modules and empty strings.
24
28
  return stdout
25
29
  .toString()
26
- .split('\n')
30
+ .split(node_os_1.EOL)
27
31
  .filter(path => !/node_modules|^$/.test(path));
28
32
  };
29
33
  exports.getCompileFiles = getCompileFiles;
package/dist/esm/duel.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { argv } from 'node:process';
2
+ import { argv, platform } from 'node:process';
3
3
  import { join, dirname, resolve, relative } from 'node:path';
4
4
  import { spawn } from 'node:child_process';
5
- import { writeFile, rm, rename, cp, mkdir } from 'node:fs/promises';
5
+ import { writeFile, rm, rename, mkdir, cp } from 'node:fs/promises';
6
6
  import { randomBytes } from 'node:crypto';
7
7
  import { performance } from 'node:perf_hooks';
8
8
  import { glob } from 'glob';
@@ -35,7 +35,7 @@ const duel = async (args) => {
35
35
  const runBuild = (project, outDir) => {
36
36
  return new Promise((resolve, reject) => {
37
37
  const args = outDir ? ['-p', project, '--outDir', outDir] : ['-p', project];
38
- const build = spawn(tsc, args, { stdio: 'inherit' });
38
+ const build = spawn(tsc, args, { stdio: 'inherit', shell: platform === 'win32' });
39
39
  build.on('error', err => {
40
40
  reject(new Error(`Failed to compile: ${err.message}`));
41
41
  });
@@ -1,7 +1,7 @@
1
1
  export function init(args: any): Promise<false | {
2
2
  pkg: import("read-package-up").NormalizedReadResult;
3
- dirs: boolean | undefined;
4
- modules: boolean | undefined;
3
+ dirs: boolean;
4
+ modules: boolean;
5
5
  tsconfig: any;
6
6
  projectDir: string;
7
7
  configPath: string;
package/dist/esm/util.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { pathToFileURL } from 'node:url';
2
2
  import { realpath } from 'node:fs/promises';
3
3
  import { spawnSync } from 'node:child_process';
4
- import { cwd } from 'node:process';
4
+ import { cwd, platform } from 'node:process';
5
+ import { EOL } from 'node:os';
5
6
  const log = (color = '\x1b[30m', msg = '') => {
6
7
  // eslint-disable-next-line no-console
7
8
  console.log(`${color}%s\x1b[0m`, msg);
@@ -13,11 +14,14 @@ const getRealPathAsFileUrl = async (path) => {
13
14
  return asFileUrl;
14
15
  };
15
16
  const getCompileFiles = (tscBinPath, wd = cwd()) => {
16
- const { stdout } = spawnSync(tscBinPath, ['--listFilesOnly'], { cwd: wd });
17
+ const { stdout } = spawnSync(tscBinPath, ['--listFilesOnly'], {
18
+ cwd: wd,
19
+ shell: platform === 'win32',
20
+ });
17
21
  // Exclude node_modules and empty strings.
18
22
  return stdout
19
23
  .toString()
20
- .split('\n')
24
+ .split(EOL)
21
25
  .filter(path => !/node_modules|^$/.test(path));
22
26
  };
23
27
  export { log, logError, getRealPathAsFileUrl, getCompileFiles };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knighted/duel",
3
- "version": "2.0.0-rc.1",
3
+ "version": "2.0.0",
4
4
  "description": "TypeScript dual packages.",
5
5
  "type": "module",
6
6
  "main": "dist/esm/duel.js",
@@ -18,11 +18,11 @@
18
18
  },
19
19
  "engineStrict": true,
20
20
  "scripts": {
21
- "prettier": "prettier -w src/*.js test/*.js",
21
+ "prettier": "prettier -w *.js src/*.js test/*.js",
22
22
  "lint": "eslint src/*.js test/*.js",
23
23
  "test:integration": "node --test --test-reporter=spec test/integration.js",
24
24
  "test:monorepos": "node --test --test-reporter=spec test/monorepos.js",
25
- "test": "c8 --reporter=text --reporter=text-summary --reporter=lcov node --test --test-reporter=spec test/*.js",
25
+ "test": "c8 --reporter=text --reporter=text-summary --reporter=lcov node --test --test-reporter=spec test/integration.js test/monorepos.js",
26
26
  "build": "node src/duel.js --dirs",
27
27
  "prepack": "npm run build"
28
28
  },
@@ -53,17 +53,19 @@
53
53
  "url": "https://github.com/knightedcodemonkey/duel/issues"
54
54
  },
55
55
  "peerDependencies": {
56
- "typescript": ">=4.0.0 || >=4.9.0-dev || >=5.3.0-dev || >=5.4.0-dev || >=5.5.0-dev || next"
56
+ "typescript": ">=5.5.0-dev || >=5.6.0-dev || >=5.7.0-dev || next"
57
57
  },
58
58
  "devDependencies": {
59
- "@types/node": "^20.11.0",
60
- "c8": "^8.0.1",
61
- "eslint": "^8.45.0",
62
- "eslint-plugin-n": "^16.0.1",
63
- "prettier": "^3.2.4",
64
- "tsx": "^4.11.2",
65
- "typescript": "^5.5.0-dev.20240525",
66
- "vite": "^5.2.8"
59
+ "@eslint/js": "^9.6.0",
60
+ "@types/node": "^22.7.4",
61
+ "c8": "^10.1.3",
62
+ "eslint": "^9.16.0",
63
+ "eslint-plugin-n": "^17.15.0",
64
+ "globals": "^15.6.0",
65
+ "prettier": "^3.4.2",
66
+ "tsx": "^4.19.1",
67
+ "typescript": "^5.7.2",
68
+ "vite": "^6.0.3"
67
69
  },
68
70
  "dependencies": {
69
71
  "@knighted/module": "^1.0.0-alpha.4",