create-platformatic 0.43.1 → 0.44.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-platformatic",
3
- "version": "0.43.1",
3
+ "version": "0.44.0",
4
4
  "description": "Create platformatic-db interactive tool",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,7 +34,7 @@
34
34
  "semver": "^7.5.1",
35
35
  "undici": "^5.22.1",
36
36
  "which": "^3.0.1",
37
- "@platformatic/config": "0.43.1"
37
+ "@platformatic/config": "0.44.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "ajv": "^8.12.0",
@@ -47,8 +47,8 @@
47
47
  "tap": "^16.3.6",
48
48
  "typescript": "~5.2.0",
49
49
  "yaml": "^2.3.1",
50
- "@platformatic/db": "0.43.1",
51
- "@platformatic/service": "0.43.1"
50
+ "@platformatic/db": "0.44.0",
51
+ "@platformatic/service": "0.44.0"
52
52
  },
53
53
  "scripts": {
54
54
  "test": "standard | snazzy && cross-env NODE_OPTIONS=\"--loader=esmock --no-warnings\" c8 tap --no-coverage test/*test.mjs test/*/*test.mjs",
@@ -233,23 +233,13 @@ const createPlatformaticDB = async (_args, opts) => {
233
233
  }
234
234
  }
235
235
  if (generatePlugin) {
236
- const { generateTypes } = await inquirer.prompt([{
237
- type: 'list',
238
- name: 'generateTypes',
239
- message: 'Do you want to generate types?',
240
- default: true,
241
- choices: [{ name: 'yes', value: true }, { name: 'no', value: false }]
242
- }])
243
-
244
- if (generateTypes) {
245
- const spinner = ora('Generating types...').start()
246
- try {
247
- await execa(pkgManager, ['exec', 'platformatic', 'db', 'types'], { cwd: projectDir })
248
- spinner.succeed('...done!')
249
- } catch (err) {
250
- logger.trace({ err })
251
- spinner.fail('...failed! Try again by running "platformatic db types"')
252
- }
236
+ const spinner = ora('Generating types...').start()
237
+ try {
238
+ await execa(pkgManager, ['exec', 'platformatic', 'db', 'types'], { cwd: projectDir })
239
+ spinner.succeed('...done!')
240
+ } catch (err) {
241
+ logger.trace({ err })
242
+ spinner.fail('...failed! Try again by running "platformatic db types"')
253
243
  }
254
244
  }
255
245
  }
@@ -78,13 +78,24 @@ const createPlatformaticService = async (_args, opts = {}) => {
78
78
  const fastifyVersion = await getDependencyVersion('fastify')
79
79
 
80
80
  if (!opts.skipPackageJson) {
81
- await createPackageJson(version, fastifyVersion, logger, projectDir, useTypescript)
81
+ await createPackageJson(version, fastifyVersion, logger, projectDir, useTypescript, {}, {
82
+ '@platformatic/service': '^' + version
83
+ })
82
84
  }
83
85
  if (!opts.skipGitignore) {
84
86
  await createGitignore(logger, projectDir)
85
87
  }
86
88
  await createReadme(logger, projectDir)
87
89
 
90
+ const spinner = ora('Generating types...').start()
91
+ try {
92
+ await execa(pkgManager, ['exec', 'platformatic', 'service', 'types'], { cwd: projectDir })
93
+ spinner.succeed('...done!')
94
+ } catch (err) {
95
+ logger.trace({ err })
96
+ spinner.fail('...failed! Try again by running "platformatic service types"')
97
+ }
98
+
88
99
  if (runPackageManagerInstall) {
89
100
  const spinner = ora('Installing dependencies...').start()
90
101
  await execa(pkgManager, ['install'], { cwd: projectDir })
@@ -56,7 +56,7 @@ PLT_TYPESCRIPT=true
56
56
  }
57
57
 
58
58
  const JS_PLUGIN_WITH_TYPES_SUPPORT = `\
59
- /// <reference types="@platformatic/service" />
59
+ /// <reference types="../global.d.ts" />
60
60
  'use strict'
61
61
  /** @param {import('fastify').FastifyInstance} fastify */
62
62
  module.exports = async function (fastify, opts) {
@@ -65,7 +65,7 @@ module.exports = async function (fastify, opts) {
65
65
  `
66
66
 
67
67
  const TS_PLUGIN_WITH_TYPES_SUPPORT = `\
68
- /// <reference types="@platformatic/service" />
68
+ /// <reference types="../global.d.ts" />
69
69
  import { FastifyInstance, FastifyPluginOptions } from 'fastify'
70
70
 
71
71
  export default async function (fastify: FastifyInstance, opts: FastifyPluginOptions) {
@@ -74,7 +74,7 @@ export default async function (fastify: FastifyInstance, opts: FastifyPluginOpti
74
74
  `
75
75
 
76
76
  const JS_ROUTES_WITH_TYPES_SUPPORT = `\
77
- /// <reference types="@platformatic/service" />
77
+ /// <reference types="../global.d.ts" />
78
78
  'use strict'
79
79
  /** @param {import('fastify').FastifyInstance} fastify */
80
80
  module.exports = async function (fastify, opts) {
@@ -85,7 +85,7 @@ module.exports = async function (fastify, opts) {
85
85
  `
86
86
 
87
87
  const TS_ROUTES_WITH_TYPES_SUPPORT = `\
88
- /// <reference types="@platformatic/service" />
88
+ /// <reference types="../global.d.ts" />
89
89
  import { FastifyInstance, FastifyPluginOptions } from 'fastify'
90
90
 
91
91
  declare module 'fastify' {
@@ -180,6 +180,7 @@ async function createService ({ hostname, port, typescript = false }, logger, cu
180
180
  } else {
181
181
  logger.info('Routes folder "routes" found, skipping creation of routes folder.')
182
182
  }
183
+
183
184
  const output = {
184
185
  PLT_SERVER_LOGGER_LEVEL: 'info',
185
186
  PORT: port,