@fullstackunicorn/root 1.0.0

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.cmd.js ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ import '@fullstackunicorn/initialize'
3
+ F3.service = '@fullstackunicorn/root'
4
+ import { init, generate, upgrade } from '#@/index.js'
5
+
6
+ const [nodePath, nodeScriptPath, command, ...args] = process.argv
7
+
8
+ if (!command) {
9
+ console.error('Error: invalid arguments. See documentation.')
10
+ console.error('Usage: yarn root <init|generate|upgrade> [args...]')
11
+ process.exit(1)
12
+ }
13
+
14
+ try {
15
+
16
+ if (command === 'init') {
17
+ const [foldername] = args
18
+ await init.run(foldername ?? null)
19
+ process.exit(0)
20
+ }
21
+
22
+ if (command === 'generate') {
23
+ await generate.run(...args)
24
+ process.exit(0)
25
+ }
26
+
27
+ if (command === 'upgrade') {
28
+ await upgrade.run(...args)
29
+ process.exit(0)
30
+ }
31
+
32
+ console.error(`Error: command "${command}" not found.`)
33
+ console.error('Available commands:')
34
+ console.error(' - init [foldername]')
35
+ console.error(' - generate')
36
+ console.error(' - upgrade')
37
+ process.exit(1)
38
+
39
+ } catch (err) {
40
+ console.error('Error:', (globalThis.F3?.err?.toStr?.(err)) ? F3.err.toStr(err) : err)
41
+ process.exit(1)
42
+ }
package/index.dep.js ADDED
@@ -0,0 +1,6 @@
1
+ // NODE BUILT IN
2
+ export { default as path } from 'path'
3
+ export { fileURLToPath } from 'url'
4
+
5
+ // FULLSTACKUNICORN
6
+ import { fsa } from '@fullstackunicorn/filesystem'
package/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import '#@/initialize.js'
2
+
3
+ export { init } from '#@/modules/root.init.js'
4
+ export { generate } from '#@/modules/root.generate.js'
5
+ export { upgrade } from '#@/modules/root.upgrade.js'
@@ -0,0 +1,8 @@
1
+ class Generate {
2
+
3
+ async run() {
4
+ console.log('root generate (TODO)')
5
+ }
6
+ }
7
+
8
+ export const generate = new Generate()
@@ -0,0 +1,29 @@
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()
@@ -0,0 +1,8 @@
1
+ class Upgrade {
2
+
3
+ async run() {
4
+ console.log('root upgrade (TODO)')
5
+ }
6
+ }
7
+
8
+ export const upgrade = new Upgrade()
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "version": "1.0.0",
3
+ "name": "@fullstackunicorn/root",
4
+ "author": "lucanigido (https://fullstackunicorn.dev/author/lucanigido)",
5
+ "description": "Root CLI: init config, generate project, upgrade project",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "private": false,
9
+ "readme": "package.readme.md",
10
+ "files": [
11
+ "index.cmd.js",
12
+ "index.js",
13
+ "index.dep.js",
14
+ "modules/"
15
+ ],
16
+ "bin": {
17
+ "root": "./index.cmd.js"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://gitlab.com/fullstackunicorn/root.git"
22
+ },
23
+ "keywords": [
24
+ "cli",
25
+ "root",
26
+ "project",
27
+ "javascript",
28
+ "node",
29
+ "fullstackunicorn"
30
+ ],
31
+ "imports": {
32
+ "#@": "./",
33
+ "#@/*": "./*"
34
+ },
35
+ "scripts": {},
36
+ "dependencies": {
37
+ "@fullstackunicorn/filesystem": "^1.0.4",
38
+ "@fullstackunicorn/initialize": "^1.0.8"
39
+ },
40
+ "devDependencies": {
41
+ "@fullstackunicorn/cli": "^1.0.3",
42
+ "@fullstackunicorn/reduce": "^1.0.20"
43
+ }
44
+ }