@fullstackunicorn/root 1.0.0 → 1.0.2
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/index.dep.js +1 -1
- package/index.js +2 -2
- package/modules/root.generate.js +47 -1
- package/modules/root.verify.js +8 -0
- package/package.json +1 -1
- package/modules/root.init.js +0 -29
package/index.dep.js
CHANGED
package/index.js
CHANGED
package/modules/root.generate.js
CHANGED
|
@@ -1,7 +1,53 @@
|
|
|
1
|
+
import { fss, path } from '#@/index.dep.js'
|
|
2
|
+
|
|
1
3
|
class Generate {
|
|
2
4
|
|
|
5
|
+
async loadConfig(cwd, filename) {
|
|
6
|
+
|
|
7
|
+
const filePath = path.join(cwd, filename)
|
|
8
|
+
|
|
9
|
+
// check exists (like reduce)
|
|
10
|
+
if (!fss.exists(filePath)) {
|
|
11
|
+
console.log(`❌ Missing ${filename} in: ${cwd}`)
|
|
12
|
+
return null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// import + cache-bust (optional but nice during dev)
|
|
16
|
+
try {
|
|
17
|
+
const mod = await import(`${filePath}?t=${Date.now()}`)
|
|
18
|
+
return mod?.default ?? null
|
|
19
|
+
} catch (err) {
|
|
20
|
+
console.log(`❌ Failed to load ${filename}`)
|
|
21
|
+
console.log(err)
|
|
22
|
+
return null
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
3
26
|
async run() {
|
|
4
|
-
|
|
27
|
+
|
|
28
|
+
const cwd = process.cwd()
|
|
29
|
+
|
|
30
|
+
const files = [
|
|
31
|
+
'root.config.app.js',
|
|
32
|
+
'root.config.frontend.js',
|
|
33
|
+
'root.config.backend.js',
|
|
34
|
+
'root.config.server.js',
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
const out = {}
|
|
38
|
+
|
|
39
|
+
for (const file of files) {
|
|
40
|
+
const cfg = await this.loadConfig(cwd, file)
|
|
41
|
+
out[file] = cfg
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// console log results
|
|
45
|
+
console.log('\n✅ root generate: loaded configs\n')
|
|
46
|
+
for (const [file, cfg] of Object.entries(out)) {
|
|
47
|
+
console.log(`=== ${file} ===`)
|
|
48
|
+
console.log(cfg)
|
|
49
|
+
console.log('')
|
|
50
|
+
}
|
|
5
51
|
}
|
|
6
52
|
}
|
|
7
53
|
|
package/package.json
CHANGED
package/modules/root.init.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { path } from '#@/index.dep.js'
|
|
2
|
-
import { fsa } from '#@/fsa.js'
|
|
3
|
-
|
|
4
|
-
class Init {
|
|
5
|
-
|
|
6
|
-
async run(foldername = null) {
|
|
7
|
-
|
|
8
|
-
const base = process.cwd()
|
|
9
|
-
|
|
10
|
-
const targetDir = foldername
|
|
11
|
-
? path.resolve(base, foldername)
|
|
12
|
-
: base
|
|
13
|
-
|
|
14
|
-
await fsa.ensureDir(targetDir)
|
|
15
|
-
|
|
16
|
-
const configPath = path.join(targetDir, 'root.config.json')
|
|
17
|
-
const readmePath = path.join(targetDir, 'root.readme.md')
|
|
18
|
-
|
|
19
|
-
// per ora vuoti
|
|
20
|
-
if (!await fsa.exists(configPath)) await fsa.writeText(configPath, '')
|
|
21
|
-
if (!await fsa.exists(readmePath)) await fsa.writeText(readmePath, '')
|
|
22
|
-
|
|
23
|
-
console.log(`✅ root init: ${targetDir}`)
|
|
24
|
-
console.log(` - ${configPath}`)
|
|
25
|
-
console.log(` - ${readmePath}`)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const init = new Init()
|