Skip to content

Commit 42e36ab

Browse files
committed
wip: converting imports
1 parent 119913e commit 42e36ab

File tree

107 files changed

+795
-795
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+795
-795
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,17 @@
109109
]
110110
},
111111
"scripts": {
112-
"prepare": "node ./scripts/build.js",
113-
"build": "node ./scripts/build.js",
114-
"version": "node ./scripts/version.js",
112+
"prepare": "node ./scripts/build.mjs",
113+
"build": "node ./scripts/build.mjs",
114+
"version": "node ./scripts/version.mjs",
115115
"postversion": "npm install --package-lock-only --ignore-scripts --silent",
116-
"dependencies": "node ./scripts/npmDepsHash.js",
116+
"dependencies": "node ./scripts/npmDepsHash.mjs",
117117
"tsx": "tsx",
118118
"test": "node ./scripts/test.mjs",
119119
"lint": "eslint '{src,tests,scripts,benches}/**/*.{js,mjs,ts,mts,jsx,tsx}'",
120120
"lintfix": "eslint '{src,tests,scripts,benches}/**/*.{js,mjs,ts,mts,jsx,tsx}' --fix",
121121
"docs": "shx rm -rf ./docs && typedoc --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src",
122-
"pkg": "node ./scripts/pkg.js",
122+
"pkg": "node ./scripts/pkg.mjs",
123123
"polykey": "ts-node src/polykey.ts",
124124
"start": "ts-node src/polykey.ts -- agent start --verbose",
125125
"dev": "nodemon src/polykey.ts -- agent start --verbose"

scripts/build.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
import os from 'node:os';
44
import fs from 'node:fs';
55
import path from 'node:path';
6+
import url from 'node:url';
67
import process from 'node:process';
78
import childProcess from 'node:child_process';
89
import esbuild from 'esbuild';
910
import polykey from 'polykey';
1011
import packageJSON from '../package.json' assert { type: 'json' };
1112

1213
const projectPath = path.dirname(
13-
path.dirname(url.fileURLToPath(import.meta.url)),
14+
path.dirname(url.fileURLToPath(import.meta.url)),
1415
);
1516

1617
const platform = os.platform();

scripts/npmDepsHash.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import fs from 'node:fs';
44
import path from 'node:path';
55
import childProcess from 'node:child_process';
6-
import url from "node:url";
6+
import url from 'node:url';
77

88
const projectPath = path.dirname(
9-
path.dirname(url.fileURLToPath(import.meta.url)),
9+
path.dirname(url.fileURLToPath(import.meta.url)),
1010
);
1111

1212
async function main(_argv = process.argv) {

scripts/pkg.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import fs from 'node:fs';
55
import path from 'node:path';
66
import process from 'node:process';
77
import childProcess from 'node:child_process';
8-
import url from "node:url";
8+
import url from 'node:url';
99
import packageJSON from '../package.json' assert { type: 'json' };
1010

1111
const projectPath = path.dirname(
12-
path.dirname(url.fileURLToPath(import.meta.url)),
12+
path.dirname(url.fileURLToPath(import.meta.url)),
1313
);
1414

1515
/**

scripts/test.mjs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,42 @@ import process from 'node:process';
77
import childProcess from 'node:child_process';
88

99
const projectPath = path.dirname(
10-
path.dirname(url.fileURLToPath(import.meta.url)),
10+
path.dirname(url.fileURLToPath(import.meta.url)),
1111
);
1212

1313
const platform = os.platform();
1414

1515
/* eslint-disable no-console */
1616
async function main(argv = process.argv) {
17-
argv = argv.slice(2);
18-
const tscArgs = [`-p`, path.join(projectPath, 'tsconfig.build.json')];
19-
console.error('Running tsc:');
20-
console.error(['tsc', ...tscArgs].join(' '));
21-
childProcess.execFileSync('tsc', tscArgs, {
22-
stdio: ['inherit', 'inherit', 'inherit'],
23-
windowsHide: true,
24-
encoding: 'utf-8',
25-
shell: platform === 'win32' ? true : false,
26-
});
27-
const jestArgs = [...argv];
28-
console.error('Running jest:');
29-
console.error(['jest', ...jestArgs].join(' '));
30-
childProcess.execFileSync('jest', jestArgs, {
31-
env: {
32-
...process.env,
33-
NODE_OPTIONS: '--experimental-vm-modules',
34-
},
35-
stdio: ['inherit', 'inherit', 'inherit'],
36-
windowsHide: true,
37-
encoding: 'utf-8',
38-
shell: platform === 'win32' ? true : false,
39-
});
17+
argv = argv.slice(2);
18+
const tscArgs = [`-p`, path.join(projectPath, 'tsconfig.build.json')];
19+
console.error('Running tsc:');
20+
console.error(['tsc', ...tscArgs].join(' '));
21+
childProcess.execFileSync('tsc', tscArgs, {
22+
stdio: ['inherit', 'inherit', 'inherit'],
23+
windowsHide: true,
24+
encoding: 'utf-8',
25+
shell: platform === 'win32' ? true : false,
26+
});
27+
const jestArgs = [...argv];
28+
console.error('Running jest:');
29+
console.error(['jest', ...jestArgs].join(' '));
30+
childProcess.execFileSync('jest', jestArgs, {
31+
env: {
32+
...process.env,
33+
NODE_OPTIONS: '--experimental-vm-modules',
34+
},
35+
stdio: ['inherit', 'inherit', 'inherit'],
36+
windowsHide: true,
37+
encoding: 'utf-8',
38+
shell: platform === 'win32' ? true : false,
39+
});
4040
}
4141
/* eslint-enable no-console */
4242

4343
if (import.meta.url.startsWith('file:')) {
44-
const modulePath = url.fileURLToPath(import.meta.url);
45-
if (process.argv[1] === modulePath) {
46-
void main();
47-
}
44+
const modulePath = url.fileURLToPath(import.meta.url);
45+
if (process.argv[1] === modulePath) {
46+
void main();
47+
}
4848
}

scripts/version.mjs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import os from 'node:os';
99
import path from 'node:path';
1010
import childProcess from 'node:child_process';
11-
import url from "node:url";
11+
import url from 'node:url';
1212

1313
const projectPath = path.dirname(
14-
path.dirname(url.fileURLToPath(import.meta.url)),
14+
path.dirname(url.fileURLToPath(import.meta.url)),
1515
);
1616

1717
const platform = os.platform();
@@ -21,12 +21,16 @@ async function main() {
2121
const npmDepsHashPath = path.join(projectPath, 'npmDepsHash');
2222

2323
console.error('Updating the npmDepsHash after version change');
24-
childProcess.execFileSync(path.join(projectPath, 'scripts/npmDepsHash.js'), [], {
25-
stdio: ['inherit', 'inherit', 'inherit'],
26-
windowsHide: true,
27-
encoding: 'utf-8',
28-
shell: platform === 'win32' ? true : false,
29-
});
24+
childProcess.execFileSync(
25+
path.join(projectPath, 'scripts/npmDepsHash.js'),
26+
[],
27+
{
28+
stdio: ['inherit', 'inherit', 'inherit'],
29+
windowsHide: true,
30+
encoding: 'utf-8',
31+
shell: platform === 'win32' ? true : false,
32+
},
33+
);
3034

3135
console.error('Staging npmDepsHash');
3236
childProcess.execFileSync('git', ['add', npmDepsHashPath], {

src/CommandPolykey.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import type { FileSystem } from 'polykey/dist/types';
1+
import type { FileSystem } from 'polykey/types.js';
22
import commander from 'commander';
33
import Logger, {
44
StreamHandler,
55
formatting,
66
levelToString,
77
evalLogDataValue,
88
} from '@matrixai/logger';
9-
import * as binUtils from './utils';
10-
import * as binOptions from './utils/options';
11-
import * as errors from './errors';
9+
import * as binUtils from './utils/index.js';
10+
import * as binOptions from './utils/options.js';
11+
import * as errors from './errors.js';
1212

1313
/**
1414
* Singleton logger constructed once for all commands

src/agent/CommandAgent.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import CommandLock from './CommandLock';
2-
import CommandLockAll from './CommandLockAll';
3-
import CommandStart from './CommandStart';
4-
import CommandStatus from './CommandStatus';
5-
import CommandStop from './CommandStop';
6-
import CommandUnlock from './CommandUnlock';
7-
import CommandPolykey from '../CommandPolykey';
1+
import CommandLock from './CommandLock.js';
2+
import CommandLockAll from './CommandLockAll.js';
3+
import CommandStart from './CommandStart.js';
4+
import CommandStatus from './CommandStatus.js';
5+
import CommandStop from './CommandStop.js';
6+
import CommandUnlock from './CommandUnlock.js';
7+
import CommandPolykey from '../CommandPolykey.js';
88

99
class CommandAgent extends CommandPolykey {
1010
constructor(...args: ConstructorParameters<typeof CommandPolykey>) {

src/agent/CommandLock.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import path from 'path';
2-
import config from 'polykey/dist/config';
3-
import CommandPolykey from '../CommandPolykey';
2+
import config from 'polykey/config.js';
3+
import CommandPolykey from '../CommandPolykey.js';
44

55
class CommandLock extends CommandPolykey {
66
constructor(...args: ConstructorParameters<typeof CommandPolykey>) {
77
super(...args);
88
this.name('lock');
99
this.description('Lock the Client and Clear the Existing Token');
1010
this.action(async (options) => {
11-
const { default: Session } = await import(
12-
'polykey/dist/sessions/Session'
13-
);
11+
const { default: Session } = await import('polykey/sessions/Session.js');
1412
const session = new Session({
1513
sessionTokenPath: path.join(options.nodePath, config.paths.tokenBase),
1614
fs: this.fs,

src/agent/CommandLockAll.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type PolykeyClient from 'polykey/dist/PolykeyClient';
1+
import type PolykeyClient from 'polykey/PolykeyClient.js';
22
import path from 'path';
3-
import config from 'polykey/dist/config';
4-
import CommandPolykey from '../CommandPolykey';
5-
import * as binUtils from '../utils';
6-
import * as binOptions from '../utils/options';
7-
import * as binProcessors from '../utils/processors';
3+
import config from 'polykey/config.js';
4+
import CommandPolykey from '../CommandPolykey.js';
5+
import * as binUtils from '../utils/index.js';
6+
import * as binOptions from '../utils/options.js';
7+
import * as binProcessors from '../utils/processors.js';
88

99
class CommandLockAll extends CommandPolykey {
1010
constructor(...args: ConstructorParameters<typeof CommandPolykey>) {
@@ -16,11 +16,9 @@ class CommandLockAll extends CommandPolykey {
1616
this.addOption(binOptions.clientPort);
1717
this.action(async (options) => {
1818
const { default: PolykeyClient } = await import(
19-
'polykey/dist/PolykeyClient'
20-
);
21-
const { default: Session } = await import(
22-
'polykey/dist/sessions/Session'
19+
'polykey/PolykeyClient.js'
2320
);
21+
const { default: Session } = await import('polykey/sessions/Session.js');
2422
const clientOptions = await binProcessors.processClientOptions(
2523
options.nodePath,
2624
options.nodeId,

0 commit comments

Comments
 (0)