@emeryld/manager 0.2.3 → 0.2.4
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/bin/manager-cli.js +32 -14
- package/dist/manager-cli.js +32 -14
- package/package.json +1 -1
package/bin/manager-cli.js
CHANGED
|
@@ -1,28 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawnSync } from 'node:child_process'
|
|
3
|
+
import { existsSync } from 'node:fs'
|
|
3
4
|
import path from 'node:path'
|
|
4
|
-
import { fileURLToPath
|
|
5
|
+
import { fileURLToPath } from 'node:url'
|
|
5
6
|
import { createRequire } from 'node:module'
|
|
6
7
|
|
|
7
8
|
const __filename = fileURLToPath(import.meta.url)
|
|
8
9
|
const __dirname = path.dirname(__filename)
|
|
9
10
|
const packageRoot = path.resolve(__dirname, '..')
|
|
10
11
|
const tsconfigPath = path.join(packageRoot, 'tsconfig.base.json')
|
|
11
|
-
const
|
|
12
|
+
const compiledEntry = path.join(packageRoot, 'dist', 'publish.js')
|
|
13
|
+
const sourceEntry = path.join(packageRoot, 'src', 'publish.ts')
|
|
14
|
+
const args = process.argv.slice(2)
|
|
12
15
|
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const registerCode = [
|
|
16
|
-
'import { register } from "node:module";',
|
|
17
|
-
'import { pathToFileURL } from "node:url";',
|
|
18
|
-
`register(${JSON.stringify(tsNodeLoader)}, pathToFileURL(${JSON.stringify(packageRoot + path.sep)}));`,
|
|
19
|
-
].join(' ')
|
|
20
|
-
const registerImport = `data:text/javascript,${encodeURIComponent(registerCode)}`
|
|
16
|
+
const hasCompiledEntry = existsSync(compiledEntry)
|
|
17
|
+
const hasSourceEntry = existsSync(sourceEntry)
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
let nodeArgs
|
|
20
|
+
let execOptions
|
|
21
|
+
|
|
22
|
+
if (hasCompiledEntry) {
|
|
23
|
+
nodeArgs = [compiledEntry, ...args]
|
|
24
|
+
execOptions = { env: process.env, stdio: 'inherit' }
|
|
25
|
+
} else if (hasSourceEntry) {
|
|
26
|
+
const require = createRequire(import.meta.url)
|
|
27
|
+
const tsNodeLoader = require.resolve('ts-node/esm.mjs')
|
|
28
|
+
const registerCode = [
|
|
29
|
+
'import { register } from "node:module";',
|
|
30
|
+
'import { pathToFileURL } from "node:url";',
|
|
31
|
+
`register(${JSON.stringify(tsNodeLoader)}, pathToFileURL(${JSON.stringify(packageRoot + path.sep)}));`,
|
|
32
|
+
].join(' ')
|
|
33
|
+
const registerImport = `data:text/javascript,${encodeURIComponent(registerCode)}`
|
|
34
|
+
nodeArgs = ['--import', registerImport, sourceEntry, ...args]
|
|
35
|
+
execOptions = {
|
|
36
|
+
env: { ...process.env, TS_NODE_PROJECT: tsconfigPath },
|
|
37
|
+
stdio: 'inherit',
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
console.error(
|
|
41
|
+
`manager-cli could not find a publish entry point (checked ${compiledEntry} and ${sourceEntry}).`,
|
|
42
|
+
)
|
|
43
|
+
process.exit(1)
|
|
26
44
|
}
|
|
27
45
|
|
|
28
46
|
const child = spawnSync(process.execPath, nodeArgs, execOptions)
|
package/dist/manager-cli.js
CHANGED
|
@@ -1,28 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawnSync } from 'node:child_process'
|
|
3
|
+
import { existsSync } from 'node:fs'
|
|
3
4
|
import path from 'node:path'
|
|
4
|
-
import { fileURLToPath
|
|
5
|
+
import { fileURLToPath } from 'node:url'
|
|
5
6
|
import { createRequire } from 'node:module'
|
|
6
7
|
|
|
7
8
|
const __filename = fileURLToPath(import.meta.url)
|
|
8
9
|
const __dirname = path.dirname(__filename)
|
|
9
10
|
const packageRoot = path.resolve(__dirname, '..')
|
|
10
11
|
const tsconfigPath = path.join(packageRoot, 'tsconfig.base.json')
|
|
11
|
-
const
|
|
12
|
+
const compiledEntry = path.join(packageRoot, 'dist', 'publish.js')
|
|
13
|
+
const sourceEntry = path.join(packageRoot, 'src', 'publish.ts')
|
|
14
|
+
const args = process.argv.slice(2)
|
|
12
15
|
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const registerCode = [
|
|
16
|
-
'import { register } from "node:module";',
|
|
17
|
-
'import { pathToFileURL } from "node:url";',
|
|
18
|
-
`register(${JSON.stringify(tsNodeLoader)}, pathToFileURL(${JSON.stringify(packageRoot + path.sep)}));`,
|
|
19
|
-
].join(' ')
|
|
20
|
-
const registerImport = `data:text/javascript,${encodeURIComponent(registerCode)}`
|
|
16
|
+
const hasCompiledEntry = existsSync(compiledEntry)
|
|
17
|
+
const hasSourceEntry = existsSync(sourceEntry)
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
let nodeArgs
|
|
20
|
+
let execOptions
|
|
21
|
+
|
|
22
|
+
if (hasCompiledEntry) {
|
|
23
|
+
nodeArgs = [compiledEntry, ...args]
|
|
24
|
+
execOptions = { env: process.env, stdio: 'inherit' }
|
|
25
|
+
} else if (hasSourceEntry) {
|
|
26
|
+
const require = createRequire(import.meta.url)
|
|
27
|
+
const tsNodeLoader = require.resolve('ts-node/esm.mjs')
|
|
28
|
+
const registerCode = [
|
|
29
|
+
'import { register } from "node:module";',
|
|
30
|
+
'import { pathToFileURL } from "node:url";',
|
|
31
|
+
`register(${JSON.stringify(tsNodeLoader)}, pathToFileURL(${JSON.stringify(packageRoot + path.sep)}));`,
|
|
32
|
+
].join(' ')
|
|
33
|
+
const registerImport = `data:text/javascript,${encodeURIComponent(registerCode)}`
|
|
34
|
+
nodeArgs = ['--import', registerImport, sourceEntry, ...args]
|
|
35
|
+
execOptions = {
|
|
36
|
+
env: { ...process.env, TS_NODE_PROJECT: tsconfigPath },
|
|
37
|
+
stdio: 'inherit',
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
console.error(
|
|
41
|
+
`manager-cli could not find a publish entry point (checked ${compiledEntry} and ${sourceEntry}).`,
|
|
42
|
+
)
|
|
43
|
+
process.exit(1)
|
|
26
44
|
}
|
|
27
45
|
|
|
28
46
|
const child = spawnSync(process.execPath, nodeArgs, execOptions)
|