@platformatic/node 2.67.0 → 2.67.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/bin/create.js +32 -0
- package/bin/start.js +36 -0
- package/index.js +1 -1
- package/lib/generator.js +14 -3
- package/package.json +11 -7
- package/schema.json +1 -1
package/bin/create.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { basename, join } from 'node:path'
|
|
4
|
+
import { parseArgs } from 'node:util'
|
|
5
|
+
import { Generator } from '../lib/generator.js'
|
|
6
|
+
|
|
7
|
+
async function execute () {
|
|
8
|
+
const args = parseArgs({
|
|
9
|
+
args: process.argv.slice(2),
|
|
10
|
+
options: {
|
|
11
|
+
dir: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
default: join(process.cwd(), 'plt-node')
|
|
14
|
+
},
|
|
15
|
+
main: { type: 'string', default: 'index.js' }
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const generator = new Generator()
|
|
20
|
+
|
|
21
|
+
generator.setConfig({
|
|
22
|
+
targetDirectory: args.values.dir,
|
|
23
|
+
serviceName: basename(args.values.dir),
|
|
24
|
+
main: args.values.main
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
await generator.run()
|
|
28
|
+
|
|
29
|
+
console.log('Application created successfully! Run `npm run start` to start an application.')
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
execute()
|
package/bin/start.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { findConfigurationFile, loadConfigurationFile } from '@platformatic/config'
|
|
4
|
+
import { ensureLoggableError } from '@platformatic/utils'
|
|
5
|
+
import { buildStackable } from '../index.js'
|
|
6
|
+
|
|
7
|
+
async function execute () {
|
|
8
|
+
const root = process.cwd()
|
|
9
|
+
const configurationFile = await findConfigurationFile(root)
|
|
10
|
+
|
|
11
|
+
const stackable = await buildStackable({
|
|
12
|
+
config: await loadConfigurationFile(configurationFile),
|
|
13
|
+
context: {
|
|
14
|
+
directory: process.cwd(),
|
|
15
|
+
serverConfig: configurationFile?.runtime?.server ?? {},
|
|
16
|
+
isEntrypoint: true,
|
|
17
|
+
isProduction: true,
|
|
18
|
+
runtimeConfig: {
|
|
19
|
+
logger: {
|
|
20
|
+
level: 'info',
|
|
21
|
+
pretty: true
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
// Set the location of the config
|
|
29
|
+
const url = await stackable.start({ listen: true })
|
|
30
|
+
stackable.logger.info('Server listening on %s', url)
|
|
31
|
+
} catch (error) {
|
|
32
|
+
stackable.logger.error({ error: ensureLoggableError(error) }, 'Error starting the application.')
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
execute()
|
package/index.js
CHANGED
package/lib/generator.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { BaseGenerator } from '@platformatic/generators'
|
|
4
|
+
import { basename, dirname, sep } from 'node:path'
|
|
4
5
|
|
|
5
6
|
const indexFile = `
|
|
6
7
|
import { createServer } from 'node:http'
|
|
@@ -26,9 +27,18 @@ export class Generator extends BaseGenerator {
|
|
|
26
27
|
return
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
const main = this.config.main || 'index.js'
|
|
31
|
+
let indexPath = ''
|
|
32
|
+
let indexName = main
|
|
33
|
+
|
|
34
|
+
if (main.indexOf(sep) !== -1) {
|
|
35
|
+
indexPath = dirname(main)
|
|
36
|
+
indexName = basename(main)
|
|
37
|
+
}
|
|
38
|
+
|
|
29
39
|
await this.getPlatformaticVersion()
|
|
30
40
|
|
|
31
|
-
this.addFile({ path:
|
|
41
|
+
this.addFile({ path: indexPath, file: indexName, contents: indexFile.trim() + '\n' })
|
|
32
42
|
|
|
33
43
|
this.addFile({
|
|
34
44
|
path: '',
|
|
@@ -36,9 +46,10 @@ export class Generator extends BaseGenerator {
|
|
|
36
46
|
contents: JSON.stringify(
|
|
37
47
|
{
|
|
38
48
|
name: `${this.config.serviceName}`,
|
|
39
|
-
main
|
|
49
|
+
main,
|
|
50
|
+
type: 'module',
|
|
40
51
|
scripts: {
|
|
41
|
-
start: 'node
|
|
52
|
+
start: 'start-platformatic-node'
|
|
42
53
|
},
|
|
43
54
|
dependencies: {
|
|
44
55
|
'@platformatic/node': `^${this.platformaticVersion}`
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/node",
|
|
3
|
-
"version": "2.67.
|
|
3
|
+
"version": "2.67.1",
|
|
4
4
|
"description": "Platformatic Node.js Stackable",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"create-platformatic-node": "./bin/create.js",
|
|
9
|
+
"start-platformatic-node": "./bin/start.js"
|
|
10
|
+
},
|
|
7
11
|
"repository": {
|
|
8
12
|
"type": "git",
|
|
9
13
|
"url": "git+https://github.com/platformatic/platformatic.git"
|
|
@@ -17,10 +21,10 @@
|
|
|
17
21
|
"dependencies": {
|
|
18
22
|
"json5": "^2.2.3",
|
|
19
23
|
"light-my-request": "^6.0.0",
|
|
20
|
-
"@platformatic/basic": "2.67.
|
|
21
|
-
"@platformatic/
|
|
22
|
-
"@platformatic/utils": "2.67.
|
|
23
|
-
"@platformatic/
|
|
24
|
+
"@platformatic/basic": "2.67.1",
|
|
25
|
+
"@platformatic/generators": "2.67.1",
|
|
26
|
+
"@platformatic/utils": "2.67.1",
|
|
27
|
+
"@platformatic/config": "2.67.1"
|
|
24
28
|
},
|
|
25
29
|
"devDependencies": {
|
|
26
30
|
"borp": "^0.20.0",
|
|
@@ -32,8 +36,8 @@
|
|
|
32
36
|
"neostandard": "^0.12.0",
|
|
33
37
|
"tsx": "^4.19.0",
|
|
34
38
|
"typescript": "^5.5.4",
|
|
35
|
-
"@platformatic/
|
|
36
|
-
"@platformatic/
|
|
39
|
+
"@platformatic/service": "2.67.1",
|
|
40
|
+
"@platformatic/composer": "2.67.1"
|
|
37
41
|
},
|
|
38
42
|
"scripts": {
|
|
39
43
|
"test": "pnpm run lint && borp --concurrency=1 --no-timeout",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/node/2.67.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/node/2.67.1.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Node.js Stackable",
|
|
5
5
|
"type": "object",
|