@platformatic/generators 2.0.0-alpha.9 → 2.0.1

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.js CHANGED
@@ -1,12 +1,10 @@
1
1
  'use strict'
2
2
 
3
3
  const { BaseGenerator } = require('./lib/base-generator')
4
- const { StackableGenerator } = require('./lib/stackable-generator')
5
4
  const { generateTests } = require('./lib/create-plugin')
6
5
  const utils = require('./lib/utils')
7
6
  module.exports = {
8
7
  BaseGenerator,
9
- StackableGenerator,
10
8
  generateTests,
11
9
  ...utils,
12
10
  }
@@ -2,12 +2,12 @@
2
2
 
3
3
  const { readFile } = require('node:fs/promises')
4
4
  const {
5
- stripVersion,
6
5
  convertServiceNameToPrefix,
7
6
  extractEnvVariablesFromText,
8
7
  getPackageConfigurationObject,
9
8
  PLT_ROOT,
10
9
  getLatestNpmVersion,
10
+ stripVersion,
11
11
  } = require('./utils')
12
12
  const { join } = require('node:path')
13
13
  const { FileGenerator } = require('./file-generator')
@@ -373,7 +373,7 @@ class BaseGenerator extends FileGenerator {
373
373
 
374
374
  async getPlatformaticVersion () {
375
375
  const pkgData = await this.readPackageJsonFile()
376
- this.platformaticVersion = stripVersion(pkgData.version)
376
+ this.platformaticVersion = pkgData.version
377
377
  }
378
378
 
379
379
  async generatePackageJson () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/generators",
3
- "version": "2.0.0-alpha.9",
3
+ "version": "2.0.1",
4
4
  "description": "Main classes and utils for generators.",
5
5
  "main": "index.js",
6
6
  "keywords": [],
@@ -10,10 +10,10 @@
10
10
  "@fastify/error": "^4.0.0",
11
11
  "boring-name-generator": "^1.0.3",
12
12
  "change-case-all": "^2.1.0",
13
- "fastify": "5.0.0-alpha.4",
13
+ "fastify": "^5.0.0",
14
14
  "pino": "^9.0.0",
15
15
  "undici": "^6.9.0",
16
- "@platformatic/utils": "2.0.0-alpha.9"
16
+ "@platformatic/utils": "2.0.1"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@types/inquirer": "^9.0.7",
@@ -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
- }