Skip to content

Commit d51bec8

Browse files
committed
Fixed oclif not working with ESM
1 parent 726ee1a commit d51bec8

6 files changed

Lines changed: 28 additions & 28 deletions

File tree

codify-core/.mocharc.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@
77
],
88
"recursive": true,
99
"reporter": "spec",
10-
"timeout": 60000
10+
"timeout": 60000,
11+
"node-option": [
12+
"experimental-specifier-resolution=node",
13+
"loader=ts-node/esm"
14+
]
1115
}

codify-core/bin/dev.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@echo off
22

3-
node "%~dp0\dev" %*
3+
node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*

codify-core/bin/dev.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#!/usr/bin/env ts-node
2-
// eslint-disable-next-line node/shebang, unicorn/prefer-top-level-await
3-
(async () => {
4-
const oclif = await import('@oclif/core')
5-
await oclif.execute({development: true, dir: __dirname})
6-
})()
1+
#!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning
2+
3+
import { execute } from '@oclif/core'
4+
5+
await execute({ development: true, dir: import.meta.url })

codify-core/bin/run.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/usr/bin/env node
22

3-
// eslint-disable-next-line unicorn/prefer-top-level-await
4-
(async () => {
5-
const oclif = await import('@oclif/core')
6-
await oclif.execute({development: true, dir: __dirname})
7-
})()
3+
import { execute } from '@oclif/core'
4+
5+
await execute({ dir: import.meta.url })

codify-core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"@oclif/core": "^3",
88
"@oclif/plugin-help": "^5",
99
"@oclif/plugin-plugins": "^3.8.4",
10-
"eslint-config-prettier": "^9.0.0",
1110
"semver": "^7.5.4",
1211
"codify-schemas": "1.0.24",
1312
"ajv": "^8.12.0"
@@ -22,14 +21,15 @@
2221
"@types/mock-fs": "^4.13.3",
2322
"@types/node": "^18",
2423
"@types/semver": "^7.5.4",
24+
"eslint-config-prettier": "^9.0.0",
2525
"chai": "^4",
2626
"chai-as-promised": "^7.1.1",
2727
"eslint": "^8.51.0",
2828
"eslint-config-oclif": "^5",
2929
"eslint-config-oclif-typescript": "^3",
3030
"mocha": "^10",
3131
"mock-fs": "^5.2.0",
32-
"oclif": "^4.0.0",
32+
"oclif": "^4.5.7",
3333
"shx": "^0.3.3",
3434
"ts-node": "^10.9.1",
3535
"typescript": "^5",
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
import { ConfigCompiler } from '../../config-compiler/index.js';
2-
import { PluginCollection } from '../../plugins/plugin-collection.js';
3-
41
export const PlanOrchestrator = {
52
async run(rootDirectory: string): Promise<string> {
6-
const parsedProject = await ConfigCompiler.parseProject(rootDirectory);
7-
8-
const pluginCollection = await PluginCollection.create(parsedProject);
9-
const definitions = await pluginCollection.getResourceDefinitions();
10-
11-
const compiledProject = await ConfigCompiler.compileProject(parsedProject, definitions);
12-
console.log(compiledProject);
13-
const plan = await pluginCollection.getPlan(compiledProject);
3+
// const parsedProject = await ConfigCompiler.parseProject(rootDirectory);
4+
//
5+
// const pluginCollection = await PluginCollection.create(parsedProject);
6+
// const definitions = await pluginCollection.getResourceDefinitions();
7+
//
8+
// const compiledProject = await ConfigCompiler.compileProject(parsedProject, definitions);
9+
// console.log(compiledProject);
10+
// const plan = await pluginCollection.getPlan(compiledProject);
11+
//
12+
// await pluginCollection.destroy();
13+
// return JSON.stringify(plan, null, 2);
1414

15-
await pluginCollection.destroy();
16-
return JSON.stringify(plan, null, 2);
15+
return '';
1716
},
1817
};

0 commit comments

Comments
 (0)