@things-factory/shell 10.1.149 → 10.1.150
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/things-factory
CHANGED
package/bin/things-factory-dev
CHANGED
|
@@ -50,7 +50,7 @@ async function doModePrompt() {
|
|
|
50
50
|
process.env.NODE_ENV = answers.mode == 'development' ? 'development' : 'production'
|
|
51
51
|
const { config } = require('@things-factory/env')
|
|
52
52
|
|
|
53
|
-
var ormconfig = require('
|
|
53
|
+
var ormconfig = require('../dist-server/initializers/ormconfig.js')
|
|
54
54
|
|
|
55
55
|
if (ormconfig.host) {
|
|
56
56
|
await confirmHost(ormconfig.host)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/shell",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.150",
|
|
4
4
|
"description": "Core module for framework",
|
|
5
5
|
"bin": {
|
|
6
6
|
"things-factory": "bin/things-factory",
|
|
@@ -142,5 +142,5 @@
|
|
|
142
142
|
"pg": "^8.7.3",
|
|
143
143
|
"sqlite3": "^5.0.8"
|
|
144
144
|
},
|
|
145
|
-
"gitHead": "
|
|
145
|
+
"gitHead": "39c135863f5f7455dcd80b8907550a1c91a86118"
|
|
146
146
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Every module a bin script requires resolves, the way node resolves it from where the script stands.
|
|
3
|
+
*
|
|
4
|
+
* 10.1.149 gave shell an `exports` map whose `"./*": "./*"` entry adds no extension, so
|
|
5
|
+
* `require('@things-factory/shell/dist-server/server-dev')` stopped resolving and no app server started. A bin
|
|
6
|
+
* script now reaches its own package's files by a relative path, and another package's by a path that names its
|
|
7
|
+
* extension. This asks node itself — `require.resolve` in a child, from the bin directory — for every relative or
|
|
8
|
+
* `@things-factory/...` require of every bin a package declares, so an `exports` map is honoured exactly as at boot.
|
|
9
|
+
*/
|
|
10
|
+
import { spawnSync } from 'child_process'
|
|
11
|
+
import { existsSync, readdirSync, readFileSync } from 'fs'
|
|
12
|
+
import { dirname, join } from 'path'
|
|
13
|
+
|
|
14
|
+
const packagesRoot = join(__dirname, '..', '..')
|
|
15
|
+
|
|
16
|
+
const requires = readdirSync(packagesRoot).flatMap(name => {
|
|
17
|
+
const manifest = join(packagesRoot, name, 'package.json')
|
|
18
|
+
if (!existsSync(manifest)) return []
|
|
19
|
+
const bins = JSON.parse(readFileSync(manifest, 'utf8')).bin ?? {}
|
|
20
|
+
return Object.values<string>(typeof bins === 'string' ? { [name]: bins } : bins).flatMap(bin => {
|
|
21
|
+
const file = join(packagesRoot, name, bin)
|
|
22
|
+
const text = readFileSync(file, 'utf8')
|
|
23
|
+
return [...text.matchAll(/require\('((?:\.\.?\/|@things-factory\/)[^']+)'\)/g)].map(match => ({ bin: `${name}/${bin}`, dir: dirname(file), spec: match[1] }))
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
describe('bin scripts', () => {
|
|
28
|
+
it('require modules of their own and of other packages, so the check below is not empty', () => {
|
|
29
|
+
expect(requires.some(one => one.spec.startsWith('.'))).toBe(true)
|
|
30
|
+
expect(requires.some(one => one.spec.startsWith('@things-factory/'))).toBe(true)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
it.each(requires.map(one => [one.bin, one.spec, one.dir]))('%s requires %s, and node resolves it', (_bin, spec, dir) => {
|
|
34
|
+
const run = spawnSync(process.execPath, ['-e', `process.stdout.write(require.resolve(${JSON.stringify(spec)}))`], { cwd: dir, encoding: 'utf8' })
|
|
35
|
+
expect(run.stderr).toBe('')
|
|
36
|
+
expect(existsSync(run.stdout)).toBe(true)
|
|
37
|
+
})
|
|
38
|
+
})
|