@platformatic/generators 1.53.3 → 2.0.0-alpha.10
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/eslint.config.js +3 -0
- package/index.d.ts +1 -1
- package/index.js +1 -3
- package/index.test-d.ts +4 -4
- package/lib/base-generator.d.ts +25 -25
- package/lib/base-generator.js +30 -31
- package/lib/create-gitignore.js +2 -2
- package/lib/create-plugin.d.ts +4 -4
- package/lib/create-plugin.js +9 -9
- package/lib/errors.js +1 -1
- package/lib/file-generator.d.ts +14 -14
- package/lib/file-generator.js +4 -4
- package/lib/utils.d.ts +8 -9
- package/lib/utils.js +18 -37
- package/package.json +14 -13
- package/lib/create-stackable-cli.js +0 -161
- package/lib/create-stackable-files.js +0 -518
- package/lib/create-stackable-plugin.js +0 -49
- package/lib/create-stackable-tests.js +0 -395
- package/lib/stackable-generator.js +0 -317
- package/test/base-generator.test.js +0 -974
- package/test/file-generator.test.js +0 -140
- package/test/fixtures/sample-runtime/.env +0 -9
- package/test/fixtures/sample-runtime/platformatic.json +0 -19
- package/test/fixtures/sample-runtime/services/no-plugin/platformatic.json +0 -7
- package/test/fixtures/sample-runtime/services/rival/platformatic.json +0 -33
- package/test/helpers.js +0 -64
- package/test/stackable-generator.test.js +0 -114
- package/test/utils.test.js +0 -223
package/package.json
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/generators",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.10",
|
|
4
4
|
"description": "Main classes and utils for generators.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [],
|
|
7
7
|
"author": "",
|
|
8
8
|
"license": "Apache-2.0",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@fastify/error": "^
|
|
10
|
+
"@fastify/error": "^4.0.0",
|
|
11
11
|
"boring-name-generator": "^1.0.3",
|
|
12
12
|
"change-case-all": "^2.1.0",
|
|
13
|
-
"fastify": "
|
|
14
|
-
"pino": "^
|
|
15
|
-
"undici": "^6.
|
|
13
|
+
"fastify": "5.0.0-alpha.4",
|
|
14
|
+
"pino": "^9.0.0",
|
|
15
|
+
"undici": "^6.9.0",
|
|
16
|
+
"@platformatic/utils": "2.0.0-alpha.10"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
19
|
"@types/inquirer": "^9.0.7",
|
|
19
|
-
"borp": "^0.
|
|
20
|
-
"c8": "^10.
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"tsd": "^0.31.
|
|
24
|
-
"typescript": "^5.
|
|
20
|
+
"borp": "^0.17.0",
|
|
21
|
+
"c8": "^10.0.0",
|
|
22
|
+
"eslint": "9",
|
|
23
|
+
"neostandard": "^0.11.1",
|
|
24
|
+
"tsd": "^0.31.0",
|
|
25
|
+
"typescript": "^5.5.4"
|
|
25
26
|
},
|
|
26
27
|
"scripts": {
|
|
27
|
-
"lint": "
|
|
28
|
-
"test": "pnpm run lint && borp -C -X fixtures -X test --concurrency=1 && tsd"
|
|
28
|
+
"lint": "eslint",
|
|
29
|
+
"test": "pnpm run lint && borp --timeout=180000 -C -X fixtures -X test --concurrency=1 && tsd"
|
|
29
30
|
}
|
|
30
31
|
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { kebabCase } = require('change-case-all')
|
|
4
|
-
|
|
5
|
-
function getJsStackableStartCli () {
|
|
6
|
-
return `\
|
|
7
|
-
#!/usr/bin/env node
|
|
8
|
-
'use strict'
|
|
9
|
-
|
|
10
|
-
const stackable = require('../index')
|
|
11
|
-
const { start } = require('@platformatic/service')
|
|
12
|
-
const { printAndExitLoadConfigError } = require('@platformatic/config')
|
|
13
|
-
|
|
14
|
-
start(stackable, process.argv.splice(2)).catch(printAndExitLoadConfigError)
|
|
15
|
-
`
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function getTsStackableStartCli () {
|
|
19
|
-
return `\
|
|
20
|
-
#!/usr/bin/env node
|
|
21
|
-
import stackable from '../index'
|
|
22
|
-
import { start } from '@platformatic/service'
|
|
23
|
-
import { printAndExitLoadConfigError } from '@platformatic/config'
|
|
24
|
-
|
|
25
|
-
start(stackable, process.argv.splice(2)).catch(printAndExitLoadConfigError)
|
|
26
|
-
`
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function getJsStackableCreateCli (stackableName) {
|
|
30
|
-
return `\
|
|
31
|
-
#!/usr/bin/env node
|
|
32
|
-
'use strict'
|
|
33
|
-
|
|
34
|
-
const { join } = require('node:path')
|
|
35
|
-
const { parseArgs } = require('node:util')
|
|
36
|
-
const { Generator } = require('../lib/generator')
|
|
37
|
-
|
|
38
|
-
async function execute () {
|
|
39
|
-
const args = parseArgs({
|
|
40
|
-
args: process.argv.slice(2),
|
|
41
|
-
options: {
|
|
42
|
-
dir: {
|
|
43
|
-
type: 'string',
|
|
44
|
-
default: join(process.cwd(), '${kebabCase(stackableName + '-app')}')
|
|
45
|
-
},
|
|
46
|
-
port: { type: 'string', default: '3042' },
|
|
47
|
-
hostname: { type: 'string', default: '0.0.0.0' },
|
|
48
|
-
plugin: { type: 'boolean', default: true },
|
|
49
|
-
tests: { type: 'boolean', default: true },
|
|
50
|
-
typescript: { type: 'boolean', default: false },
|
|
51
|
-
git: { type: 'boolean', default: false },
|
|
52
|
-
install: { type: 'boolean', default: true }
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
const generator = new Generator()
|
|
57
|
-
|
|
58
|
-
generator.setConfig({
|
|
59
|
-
port: parseInt(args.values.port),
|
|
60
|
-
hostname: args.values.hostname,
|
|
61
|
-
plugin: args.values.plugin,
|
|
62
|
-
tests: args.values.tests,
|
|
63
|
-
typescript: args.values.typescript,
|
|
64
|
-
initGitRepository: args.values.git,
|
|
65
|
-
targetDirectory: args.values.dir
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
await generator.run()
|
|
69
|
-
|
|
70
|
-
console.log('Application created successfully! Run \`npm run start\` to start an application.')
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
execute()
|
|
74
|
-
`
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function getTsStackableCreateCli (stackableName) {
|
|
78
|
-
return `\
|
|
79
|
-
#!/usr/bin/env node
|
|
80
|
-
import { join } from 'node:path'
|
|
81
|
-
import { parseArgs } from 'node:util'
|
|
82
|
-
import { Generator } from '../lib/generator'
|
|
83
|
-
|
|
84
|
-
async function execute (): Promise<void> {
|
|
85
|
-
const args = parseArgs({
|
|
86
|
-
args: process.argv.slice(2),
|
|
87
|
-
options: {
|
|
88
|
-
dir: {
|
|
89
|
-
type: 'string',
|
|
90
|
-
default: join(process.cwd(), '${kebabCase(stackableName + '-app')}')
|
|
91
|
-
},
|
|
92
|
-
port: { type: 'string' },
|
|
93
|
-
hostname: { type: 'string', default: '0.0.0.0' },
|
|
94
|
-
plugin: { type: 'boolean', default: true },
|
|
95
|
-
tests: { type: 'boolean', default: true },
|
|
96
|
-
typescript: { type: 'boolean', default: false },
|
|
97
|
-
git: { type: 'boolean', default: false },
|
|
98
|
-
install: { type: 'boolean', default: true }
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
const generator = new Generator()
|
|
103
|
-
|
|
104
|
-
generator.setConfig({
|
|
105
|
-
port: parseInt(args.values.port || '3042'),
|
|
106
|
-
hostname: args.values.hostname,
|
|
107
|
-
plugin: args.values.plugin,
|
|
108
|
-
tests: args.values.tests,
|
|
109
|
-
typescript: args.values.typescript,
|
|
110
|
-
initGitRepository: args.values.git,
|
|
111
|
-
targetDirectory: args.values.dir
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
await generator.run()
|
|
115
|
-
|
|
116
|
-
console.log('Application created successfully! Run \`npm run start\` to start an application.')
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
execute().catch(err => {
|
|
120
|
-
throw err
|
|
121
|
-
})
|
|
122
|
-
`
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function generateStackableCli (typescript, stackableName) {
|
|
126
|
-
if (typescript) {
|
|
127
|
-
return [
|
|
128
|
-
{
|
|
129
|
-
path: 'cli',
|
|
130
|
-
file: 'start.ts',
|
|
131
|
-
contents: getTsStackableStartCli(),
|
|
132
|
-
options: { mode: 0o755 }
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
path: 'cli',
|
|
136
|
-
file: 'create.ts',
|
|
137
|
-
contents: getTsStackableCreateCli(stackableName),
|
|
138
|
-
options: { mode: 0o755 }
|
|
139
|
-
}
|
|
140
|
-
]
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return [
|
|
144
|
-
{
|
|
145
|
-
path: 'cli',
|
|
146
|
-
file: 'start.js',
|
|
147
|
-
contents: getJsStackableStartCli(),
|
|
148
|
-
options: { mode: 0o755 }
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
path: 'cli',
|
|
152
|
-
file: 'create.js',
|
|
153
|
-
contents: getJsStackableCreateCli(stackableName),
|
|
154
|
-
options: { mode: 0o755 }
|
|
155
|
-
}
|
|
156
|
-
]
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
module.exports = {
|
|
160
|
-
generateStackableCli
|
|
161
|
-
}
|