platformatic 2.74.3 → 3.0.0-alpha.5

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ![The Platformatic logo](https://github.com/platformatic/platformatic/raw/HEAD/assets/banner-light.png 'The Platformatic logo')
1
+ ![The Platformatic logo](https://github.com/platformatic/platformatic/raw/HEAD/assets/banner-light.png)
2
2
 
3
3
  <p align="center">
4
4
  <br/>
@@ -25,8 +25,8 @@ guide to get up and running with Platformatic.
25
25
  ## Documentation
26
26
 
27
27
  - [Getting Started](https://docs.platformatic.dev/docs/getting-started/quick-start-guide)
28
- - [CLI](https://docs.platformatic.dev/docs/cli)
29
- - [Guides](https://docs.platformatic.dev/docs/guides/movie-quotes-app-tutorial)
28
+ - [CLI](https://docs.platformatic.dev/docs/reference/platformatic/cli)
29
+ - [Guides](https://docs.platformatic.dev/docs/guides/build-modular-monolith)
30
30
 
31
31
  Check out our full documentation at [docs.platformatic.dev](https://docs.platformatic.dev).
32
32
 
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { checkNodeVersionForServices, setExecutableId, setExecutableName } from '@platformatic/foundation'
4
+ import { main } from 'wattpm'
5
+
6
+ setExecutableId('platformatic')
7
+ setExecutableName('Platformatic')
8
+ checkNodeVersionForServices()
9
+ await main()
package/bin/plt.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { checkNodeVersionForServices, setExecutableId, setExecutableName } from '@platformatic/foundation'
4
+ import { main } from 'wattpm'
5
+
6
+ setExecutableId('plt')
7
+ setExecutableName('Platformatic')
8
+ checkNodeVersionForServices()
9
+ await main()
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "platformatic",
3
- "version": "2.74.3",
3
+ "version": "3.0.0-alpha.5",
4
4
  "description": "Platformatic CLI",
5
- "main": "cli.js",
6
5
  "type": "module",
7
6
  "bin": {
8
- "platformatic": "cli.js",
9
- "plt": "cli.js"
7
+ "platformatic": "bin/platformatic.js",
8
+ "plt": "bin/plt.js"
10
9
  },
11
10
  "homepage": "https://docs.platformatic.dev/",
12
11
  "author": "Platformatic Inc. <oss@platformatic.dev> (https://platformatic.dev)",
@@ -27,50 +26,22 @@
27
26
  "mercurius"
28
27
  ],
29
28
  "devDependencies": {
30
- "add": "^2.0.6",
31
29
  "borp": "^0.20.0",
32
30
  "c8": "^10.0.0",
33
31
  "eslint": "9",
34
- "fastify": "^5.0.0",
35
32
  "license-checker": "^25.0.1",
36
- "minimatch": "^10.0.3",
37
- "mkdirp": "^2.1.6",
38
33
  "neostandard": "^0.12.0",
39
- "typescript": "^5.5.3",
40
- "@platformatic/astro": "2.74.3",
41
- "@platformatic/composer": "2.74.3",
42
- "@platformatic/node": "2.74.3",
43
- "@platformatic/remix": "2.74.3",
44
- "@platformatic/db": "2.74.3",
45
- "@platformatic/next": "2.74.3",
46
- "@platformatic/service": "2.74.3",
47
- "@platformatic/vite": "2.74.3"
34
+ "typescript": "^5.5.3"
48
35
  },
49
36
  "dependencies": {
50
- "@fastify/error": "^4.0.0",
51
- "colorette": "^2.0.20",
52
- "commist": "^3.2.0",
53
- "desm": "^1.3.1",
54
- "dotenv": "^16.4.5",
55
- "execa": "^9.3.1",
56
- "fast-json-stringify": "^6.0.0",
57
- "help-me": "^5.0.0",
58
- "minimist": "^1.2.8",
59
- "pino": "^9.4.0",
60
- "pino-pretty": "^13.0.0",
61
- "split2": "^4.2.0",
62
- "undici": "^7.0.0",
63
- "@platformatic/basic": "2.74.3",
64
- "@platformatic/config": "2.74.3",
65
- "@platformatic/client-cli": "2.74.3",
66
- "@platformatic/runtime": "2.74.3",
67
- "@platformatic/control": "2.74.3",
68
- "@platformatic/utils": "2.74.3",
69
- "create-platformatic": "2.74.3",
70
- "wattpm": "2.74.3"
37
+ "@platformatic/foundation": "3.0.0-alpha.5",
38
+ "wattpm": "3.0.0-alpha.5"
39
+ },
40
+ "engines": {
41
+ "node": ">=22.18.0"
71
42
  },
72
43
  "scripts": {
73
- "test": "pnpm run lint && borp --no-timeout --concurrency 1",
44
+ "test": "pnpm run lint && borp --timeout 1200000 --concurrency 1",
74
45
  "lint": "eslint",
75
46
  "license": "license-checker --production --onlyAllow 'Apache-2.0;MIT;ISC;BSD-2-Clause;BSD-3-Clause;CC-BY-4.0;BlueOak-1.0.0'"
76
47
  }
package/cli.js DELETED
@@ -1,119 +0,0 @@
1
- #! /usr/bin/env node
2
- import { command as client } from '@platformatic/client-cli'
3
- import {
4
- getRuntimesCommand,
5
- injectRuntimeCommand,
6
- runControl,
7
- streamRuntimeLogsCommand
8
- } from '@platformatic/control/control.js'
9
- import { startCommand } from '@platformatic/runtime'
10
- import { compile, run as runRuntime } from '@platformatic/runtime/runtime.mjs'
11
- import { checkNodeVersionForServices } from '@platformatic/utils'
12
- import { isColorSupported } from 'colorette'
13
- import commist from 'commist'
14
- import { join } from 'desm'
15
- import helpMe from 'help-me'
16
- import minimist from 'minimist'
17
- import { readFile } from 'node:fs/promises'
18
- import { createRequire } from 'node:module'
19
- import path from 'node:path'
20
- import { pathToFileURL } from 'node:url'
21
- import { logo } from './lib/ascii.js'
22
- import { build } from './lib/build.js'
23
- import { install } from './lib/install.js'
24
- import { patchConfig } from './lib/patch-config.js'
25
- import { resolve } from './lib/resolve.js'
26
- import { upgrade } from './lib/upgrade.js'
27
-
28
- checkNodeVersionForServices()
29
-
30
- const program = commist({ maxDistance: 2 })
31
- const help = helpMe({
32
- dir: join(import.meta.url, 'help'),
33
- // the default
34
- ext: '.txt'
35
- })
36
-
37
- async function load (moduleName) {
38
- const require = createRequire(path.join(process.cwd(), 'package.json'))
39
- const file = require.resolve(moduleName)
40
- return import(pathToFileURL(file))
41
- }
42
-
43
- const ensureCommand = async ({ output, help }) => {
44
- if (!output) {
45
- return
46
- }
47
-
48
- if (output.length) {
49
- console.log('Command not found:', output.join(' '), '\n')
50
- }
51
-
52
- await help.toStdout()
53
- process.exit(1)
54
- }
55
-
56
- program.register('db', async args => {
57
- const { runDB } = await load('@platformatic/db/db.mjs')
58
- return ensureCommand(await runDB(args))
59
- })
60
- program.register('runtime', async args => ensureCommand(await runRuntime(args)))
61
- program.register('service', async args => {
62
- const { runService } = await load('@platformatic/service/service.mjs')
63
- return ensureCommand(await runService(args))
64
- })
65
- program.register('composer', async args => {
66
- const { runComposer } = await load('@platformatic/composer/composer.mjs')
67
- return ensureCommand(await runComposer(args))
68
- })
69
- program.register('start', async args => ensureCommand(await startCommand(args)))
70
- program.register('ctl', async args => ensureCommand(await runControl(args)))
71
- program.register('ps', async args => getRuntimesCommand(args))
72
- program.register('inject', async args => injectRuntimeCommand(args))
73
- program.register('logs', async args => streamRuntimeLogsCommand(args))
74
- program.register('upgrade', upgrade)
75
- program.register('resolve', resolve)
76
- program.register('patch-config', patchConfig)
77
- program.register('client', client)
78
- program.register('build', build)
79
- program.register('install', install)
80
- program.register('compile', async args => ((await compile(args)) ? null : process.exit(1)))
81
- program.register('help', help.toStdout)
82
- program.register('help db', async args => {
83
- const { runDB } = await load('@platformatic/db/db.mjs')
84
- return runDB(['help', ...args])
85
- })
86
- program.register('help client', () => client([]))
87
- program.register('help runtime', async args => runRuntime(['help', ...args]))
88
- program.register('help service', async args => {
89
- const { runService } = await load('@platformatic/service/service.mjs')
90
- return runService(['help', ...args])
91
- })
92
-
93
- const args = minimist(process.argv.slice(2), {
94
- boolean: ['help', 'version'],
95
- alias: {
96
- help: 'h',
97
- version: 'v'
98
- }
99
- })
100
-
101
- if (args.version && !args._.includes('inject')) {
102
- const version = JSON.parse(await readFile(join(import.meta.url, 'package.json'), 'utf-8')).version
103
- console.log('v' + version)
104
- process.exit(0)
105
- }
106
-
107
- if (args.help) {
108
- await help.toStdout(['help'])
109
- } else if (process.argv.length > 2) {
110
- const output = await program.parseAsync(process.argv.slice(2))
111
- await ensureCommand({ output, help })
112
- /* c8 ignore start */
113
- } else {
114
- if (isColorSupported && process.stdout.isTTY) {
115
- console.log(logo)
116
- }
117
- await help.toStdout(['help'])
118
- }
119
- /* c8 ignore stop */
package/help/compile.txt DELETED
@@ -1,7 +0,0 @@
1
- Compile all typescript plugins.
2
-
3
- ``` bash
4
- $ platformatic compile
5
- ```
6
-
7
- This command will compile the TypeScript plugins for each platformatic application.
package/help/help.txt DELETED
@@ -1,19 +0,0 @@
1
- Welcome to Platformatic. Available commands are:
2
-
3
- * `db` - start Platformatic DB; type `platformatic db help` to know more.
4
- * `runtime` - start Platformatic Runtime; type `platformatic runtime help` to know more.
5
- * `service` - start Platformatic Service; type `platformatic service help` to know more.
6
- * `composer` - start Platformatic Composer; type `platformatic composer help` to know more.
7
- * `start` - start a Platformatic application.
8
- * `ctl` - Platformatic Control commands; `platformatic ctl help` to know more.
9
- * `ps` - list all Platformatic runtime applications.
10
- * `inject` - inject a request into a Platformatic runtime application.
11
- * `logs` - stream logs for a Platformatic runtime application.
12
- * `upgrade` - upgrade the Platformatic configuration to the latest version.
13
- * `resolve` - resolve Platformatic Runtime external services
14
- * `client` - generate a Platformatic client.
15
- * `build` - builds all services.
16
- * `install` - install all dependencies of an application and its services.
17
- * `compile` - compile all typescript plugins.
18
- * `help` - display this message.
19
- * `help <command>` - show more information about a command.
package/help/inject.txt DELETED
@@ -1,30 +0,0 @@
1
- Injects a request to the Platformatic runtime service.
2
-
3
- ``` bash
4
- $ platformatic inject -n runtime-name /hello
5
- -X POST
6
- -H "Content-Type: application/json"
7
- -d '{"key": "value"}'
8
- ```
9
-
10
- Options:
11
-
12
- * `-p, --pid <number>` - The process `id` of the runtime.
13
- * `-n, --name <string>` - The name of the runtime.
14
- * `-s, --service <string>` - The name of the runtime service.
15
- * `-X, --request <string>` - The request HTTP method. Default is `GET`.
16
- * `-H, --header <string>` - The request header. Can be used multiple times.
17
- * `-d, --data <string>` - The request data.
18
- * `-i, --include <boolean>` - Include the response headers in the output. Default is `false`.
19
- * `-v, --verbose <boolean>` - Make the operation more talkative. Default is `false`.
20
- * `-o, --output <file>` - Write the response to the specified file.
21
-
22
- The `inject` command sends a request to the runtime service and prints the
23
- response to the standard output. If the `--service` option is not specified the
24
- request is sent to the runtime entry point.
25
-
26
- The `inject` command uses the Platformatic Runtime Management API. To enable it
27
- set the `managementApi` option to `true` in the runtime configuration file.
28
-
29
- To get the list of runtimes with enabled management API use the
30
- `platformatic ctl ps` command.
package/help/install.txt DELETED
@@ -1,10 +0,0 @@
1
- Install all dependencies of an application and its services.
2
-
3
- ```bash
4
- platformatic install
5
- ```
6
-
7
- Options:
8
-
9
- * `-p, --production`: Only install production dependencies.
10
- * `-P, --package-manager EXECUTABLE`: Use an alternative package manager (the default is to autodetect it).
package/help/logs.txt DELETED
@@ -1,21 +0,0 @@
1
- Streams logs from the platformatic runtime application.
2
-
3
- ``` bash
4
- $ platformatic logs -n runtime-name
5
- ```
6
-
7
- Options:
8
-
9
- * `-p, --pid <number>` - The process id of the runtime.
10
- * `-n, --name <string>` - The name of the runtime.
11
- * `-l, --level <string>` - The pino log level to stream. Default is `info`.
12
- * `-s, --service <string>` - The name of the service to stream logs from.
13
- * `--pretty <boolean>` - Pretty print the logs. Default is `true`.
14
-
15
- If `--service` is not specified, the command will stream logs from all services.
16
-
17
- The `logs` command uses the Platformatic Runtime Management API. To enable it
18
- set the `managementApi` option to `true` in the runtime configuration file.
19
-
20
- To get the list of runtimes with enabled management API use the
21
- `platformatic ctl ps` command.
package/help/ps.txt DELETED
@@ -1,10 +0,0 @@
1
- Lists all running platformatic runtime applications.
2
-
3
- ``` bash
4
- $ platformatic ps
5
- ```
6
-
7
- To see the list of all available control commands, run `platformatic ctl help`.
8
-
9
- The `ps` command uses the Platformatic Runtime Management API. To enable it
10
- set the `managementApi` option to `true` in the runtime configuration file.
package/help/resolve.txt DELETED
@@ -1,58 +0,0 @@
1
- Resolve Platformatic Runtime external services
2
-
3
- ``` bash
4
- $ platformatic resolve
5
- ```
6
-
7
- Options:
8
-
9
- * `-c, --config FILE` - Path to the runtime configuration file.
10
- * `-u, --username string` - Username for the service repository.
11
- * `-p, --password string` - Password for the service repository.
12
- * `-P, --package-manager EXECUTABLE`: Use an alternative package manager to install dependencies (the default is to autodetect it).
13
-
14
- Platformatic resolve command resolves runtime services that have the `url` in their configuration.
15
- By default services are cloned with `git` to the `external` directory inside the runtime directory.
16
- To change the directory where a service is cloned, you can set the `path` property in the service configuration.
17
-
18
- After cloning the service, the resolve command will set the relative path to the service in the runtime configuration file.
19
-
20
- Example of the runtime platformatic.json configuration file:
21
-
22
- ```json
23
- {
24
- "$schema": "https://schemas.platformatic.dev/@platformatic/runtime/2.0.0.json",
25
- "entrypoint": "service-1",
26
- "services": [
27
- {
28
- "id": "service-1",
29
- "path": "./services/service-1",
30
- "config": "platformatic.json"
31
- },
32
- {
33
- "id": "service-2",
34
- "config": "platformatic.json",
35
- "url": "https://github.com/test-owner/test-service.git"
36
- },
37
- {
38
- "id": "service-3",
39
- "config": "platformatic.json",
40
- "path": "./custom-external/service-3",
41
- "url": "https://github.com/test-owner/test-service.git"
42
- }
43
- ],
44
- }
45
- ```
46
-
47
- If not specified, the configuration will be loaded from any of the following, in the current directory.
48
-
49
- * `platformatic.json`, or
50
- * `platformatic.yml`, or
51
- * `platformatic.tml`, or
52
- * `platformatic.json`, or
53
- * `platformatic.yml`, or
54
- * `platformatic.tml`
55
-
56
- You can find more details about the configuration format here:
57
- * [Platformatic DB Configuration](https://docs.platformatic.dev/docs/db/configuration)
58
- * [Platformatic Service Configuration](https://docs.platformatic.dev/docs/service/configuration)
package/help/start.txt DELETED
@@ -1,11 +0,0 @@
1
- Start a Platformatic application with the following command:
2
-
3
- ```bash
4
- $ platformatic start
5
- ```
6
-
7
- Options:
8
-
9
- * `-c, --config <path>` - Path to the configuration file.
10
- * `--inspect[=[host:]port]` - Start the Node.js debugger. `host` defaults to `'127.0.0.1'`. `port` defaults to 9229. Use caution when binding to a public host:port combination.
11
- * `--inspect-brk[=[host:]port]` - Start the Node.js debugger and block until a client has attached. `host` defaults to `'127.0.0.1'`. `port` defaults to 9229. Use caution when binding to a public host:port combination.
package/help/upgrade.txt DELETED
@@ -1,22 +0,0 @@
1
- Upgrade the Platformatic schema configuration to the latest version.
2
-
3
- ``` bash
4
- $ platformatic upgrade
5
- ```
6
-
7
- Options:
8
-
9
- * `-c, --config FILE` - Specify a schema configuration file to use.
10
-
11
- If not specified, the configuration will be loaded from any of the following, in the current directory.
12
-
13
- * `platformatic.json`, or
14
- * `platformatic.yml`, or
15
- * `platformatic.tml`, or
16
- * `platformatic.json`, or
17
- * `platformatic.yml`, or
18
- * `platformatic.tml`
19
-
20
- You can find more details about the configuration format here:
21
- * [Platformatic DB Configuration](https://docs.platformatic.dev/docs/db/configuration)
22
- * [Platformatic Service Configuration](https://docs.platformatic.dev/docs/service/configuration)
package/lib/ascii.js DELETED
@@ -1,37 +0,0 @@
1
- import { green } from 'colorette'
2
-
3
- const str = `
4
-
5
- //////
6
- /////////////
7
- /////// ///////
8
- /////// ///////
9
- /////// ///////
10
- //// ////
11
- &&&& //// //// &&&&
12
- &&&&&&& //// //// &&&&&&&
13
- &&&&&&& //// //// &&&&&&&
14
- &&&& //// //// &&&&&&&
15
- &&&& //// //// &&&& &&
16
- &&&& //// //// &&& &&&&&&
17
- &&&& //// //// &&& &&&&&&
18
- &&&& ///// ///// &&& &&&&
19
- &&&& /////// /////// &&& &&&&
20
- &&&& ////// /////// &&& &&&&&&&
21
- &&&& //// ///////// //////// &&& &&&&&&
22
- &&&& //// /// //////////// &&&& &&& &&&
23
- &&&&&&& //// /// ///// &&&& &&&&
24
- &&&&&&& //// &&& &&&&& &&&&&&&
25
- &&& //// &&&& &&&&&&& &&&&&&&
26
- //// &&& &&&& &&&&&&&&&&
27
- //// &&& &&&& &&&&
28
- // &&&&& &&&&
29
- &&&&&&& &&&&&&
30
- &&&&&&&&&&&&&
31
- &&&&&&
32
-
33
- `
34
-
35
- export const logo = str.replace(/\//g, function (str) {
36
- return green(str)
37
- })
package/lib/build.js DELETED
@@ -1,37 +0,0 @@
1
- import { Store, loadConfig as pltConfigLoadConfig } from '@platformatic/config'
2
- import { buildRuntime, platformaticRuntime } from '@platformatic/runtime'
3
- import { ensureLoggableError } from '@platformatic/utils'
4
-
5
- export async function build (args) {
6
- const store = new Store()
7
- store.add(platformaticRuntime)
8
-
9
- const config = await pltConfigLoadConfig({}, args, store)
10
- config.configManager.args = config.args
11
-
12
- const runtimeConfig = config.configManager
13
- const runtime = await buildRuntime(runtimeConfig)
14
- const logger = runtime.logger
15
-
16
- // Gather informations for all services before starting
17
- const { services } = await runtime.getServices()
18
-
19
- for (const { id } of services) {
20
- logger.info(`Building service "${id}" ...`)
21
-
22
- try {
23
- await runtime.buildService(id)
24
- } catch (error) {
25
- if (error.code === 'PLT_BASIC_NON_ZERO_EXIT_CODE') {
26
- logger.error(`Building service "${id}" has failed with exit code ${error.exitCode}.`)
27
- } else {
28
- logger.error({ err: ensureLoggableError(error) }, `Building service "${id}" has throw an exception.`)
29
- }
30
-
31
- process.exit(1)
32
- }
33
- }
34
-
35
- logger.info('✅ All services have been built.')
36
- await runtime.close(true)
37
- }
package/lib/errors.js DELETED
@@ -1,19 +0,0 @@
1
- 'use strict'
2
-
3
- import createError from '@fastify/error'
4
-
5
- const ERROR_PREFIX = 'PLT_CLI'
6
-
7
- const errors = {
8
- InvalidWorkspaceTypeError: createError(`${ERROR_PREFIX}_INVALID_WORKSPACE_TYPE`, 'Invalid workspace type provided: "%s". Type must be one of: %s'),
9
- InvalidWorkspaceIdError: createError(`${ERROR_PREFIX}_INVALID_WORKSPACE_ID`, 'Invalid workspace id provided. Workspace id must be a valid uuid.'),
10
- CouldNotFindWorkspaceKeysError: createError(`${ERROR_PREFIX}_COULD_NOT_FIND_WORKSPACE_KEYS`, 'Could not find workspace keys in provided file.'),
11
- CouldNotFetchUserApplicationsError: createError(`${ERROR_PREFIX}_COULD_NOT_FETCH_USER_APPLICATIONS`, 'Could not fetch user applications'),
12
- CouldNotFetchDeployLabelsError: createError(`${ERROR_PREFIX}_COULD_NOT_FETCH_DEPLOY_LABELS`, 'Could not fetch deploy labels'),
13
- CouldNotCreateWorkspaceError: createError(`${ERROR_PREFIX}_COULD_NOT_CREATE_WORKSPACE`, 'Could not create workspace'),
14
- CouldNotCreateApplicationError: createError(`${ERROR_PREFIX}_COULD_NOT_CREATE_APPLICATION`, 'Could not create application'),
15
- CouldNotFetchUserOrgsError: createError(`${ERROR_PREFIX}_COULD_NOT_FETCH_USER_ORGS`, 'Could not fetch user ogranisations'),
16
- NoUserOrgsError: createError(`${ERROR_PREFIX}_NO_USER_ORGS`, 'User does not have any organisations.'),
17
- }
18
-
19
- export default errors
package/lib/install.js DELETED
@@ -1,56 +0,0 @@
1
- import { Store } from '@platformatic/config'
2
- import { platformaticRuntime } from '@platformatic/runtime'
3
- import parseArgs from 'minimist'
4
- import pino from 'pino'
5
- import pretty from 'pino-pretty'
6
- import { installDependencies } from 'wattpm/lib/commands/build.js'
7
-
8
- export async function install (argv) {
9
- const args = parseArgs(argv, {
10
- alias: {
11
- production: 'p',
12
- 'package-manager': 'P'
13
- },
14
- boolean: ['production'],
15
- string: ['package-manager']
16
- })
17
-
18
- const logger = pino(
19
- pretty({
20
- translateTime: 'SYS:HH:MM:ss',
21
- ignore: 'hostname,pid'
22
- })
23
- )
24
-
25
- try {
26
- const store = new Store({
27
- cwd: process.cwd(),
28
- logger
29
- })
30
- store.add(platformaticRuntime)
31
-
32
- const { configManager } = await store.loadConfig({
33
- config: args.config,
34
- overrides: {
35
- onMissingEnv () {
36
- return ''
37
- }
38
- }
39
- })
40
-
41
- const installed = await installDependencies(
42
- logger,
43
- configManager.dirname,
44
- configManager.fullPath,
45
- args.production,
46
- args['package-manager']
47
- )
48
-
49
- if (installed) {
50
- logger.info('✅ All dependencies have been installed')
51
- }
52
- } catch (err) {
53
- console.log(err)
54
- process.exit(1)
55
- }
56
- }
@@ -1,47 +0,0 @@
1
- import { Store } from '@platformatic/config'
2
- import { platformaticRuntime } from '@platformatic/runtime'
3
- import parseArgs from 'minimist'
4
- import pino from 'pino'
5
- import pretty from 'pino-pretty'
6
- import { patchConfig as wattPatchConfig } from 'wattpm'
7
-
8
- export async function patchConfig (argv) {
9
- const args = parseArgs(argv, {
10
- alias: {
11
- config: 'c',
12
- patch: 'p'
13
- },
14
- string: ['config', 'patch']
15
- })
16
-
17
- const logger = pino(
18
- pretty({
19
- translateTime: 'SYS:HH:MM:ss',
20
- ignore: 'hostname,pid'
21
- })
22
- )
23
-
24
- try {
25
- const store = new Store({
26
- cwd: process.cwd(),
27
- logger
28
- })
29
- store.add(platformaticRuntime)
30
-
31
- const { configManager } = await store.loadConfig({
32
- config: args.config,
33
- overrides: {
34
- onMissingEnv () {
35
- return ''
36
- }
37
- }
38
- })
39
-
40
- await wattPatchConfig(logger, configManager.fullPath, args.patch)
41
-
42
- logger.info('✅ Patch executed correctly.')
43
- } catch (err) {
44
- console.log(err)
45
- process.exit(1)
46
- }
47
- }
package/lib/resolve.js DELETED
@@ -1,58 +0,0 @@
1
- import { Store } from '@platformatic/config'
2
- import { platformaticRuntime } from '@platformatic/runtime'
3
- import parseArgs from 'minimist'
4
- import pino from 'pino'
5
- import pretty from 'pino-pretty'
6
- import { resolveServices } from 'wattpm'
7
-
8
- export async function resolve (argv) {
9
- const args = parseArgs(argv, {
10
- alias: {
11
- config: 'c',
12
- username: 'u',
13
- password: 'p',
14
- 'package-manager': 'P'
15
- },
16
- string: ['config', 'username', 'password', 'package-manager']
17
- })
18
-
19
- const logger = pino(
20
- pretty({
21
- translateTime: 'SYS:HH:MM:ss',
22
- ignore: 'hostname,pid'
23
- })
24
- )
25
- try {
26
- const store = new Store({
27
- cwd: process.cwd(),
28
- logger
29
- })
30
- store.add(platformaticRuntime)
31
-
32
- const { configManager } = await store.loadConfig({
33
- config: args.config,
34
- overrides: {
35
- onMissingEnv () {
36
- return ''
37
- }
38
- }
39
- })
40
-
41
- const resolved = await resolveServices(
42
- logger,
43
- configManager.dirname,
44
- configManager.fullPath,
45
- args.username,
46
- args.password,
47
- false,
48
- args.packageManager
49
- )
50
-
51
- if (resolved) {
52
- logger.info('✅ All external services have been resolved')
53
- }
54
- } catch (err) {
55
- console.log(err)
56
- process.exit(1)
57
- }
58
- }
package/lib/upgrade.js DELETED
@@ -1,63 +0,0 @@
1
- import { Store, getStringifier } from '@platformatic/config'
2
- import parseArgs from 'minimist'
3
- import { writeFile } from 'fs/promises'
4
- import { platformaticRuntime } from '@platformatic/runtime'
5
- import pino from 'pino'
6
- import pretty from 'pino-pretty'
7
- import fjs from 'fast-json-stringify'
8
-
9
- export async function upgrade (argv) {
10
- const args = parseArgs(argv, {
11
- alias: {
12
- config: 'c',
13
- },
14
- })
15
-
16
- const logger = pino(pretty({
17
- translateTime: 'SYS:HH:MM:ss',
18
- ignore: 'hostname,pid',
19
- }))
20
- try {
21
- await upgradeApp(args.config, logger)
22
- } catch (err) {
23
- console.log(err)
24
- process.exit(1)
25
- }
26
- }
27
-
28
- async function upgradeApp (config, logger) {
29
- const store = new Store({
30
- cwd: process.cwd(),
31
- logger,
32
- })
33
- store.add(platformaticRuntime)
34
-
35
- const { configManager } = await store.loadConfig({
36
- config,
37
- overrides: {
38
- fixPaths: false,
39
- onMissingEnv (key) {
40
- return '{' + key + '}'
41
- },
42
- },
43
- })
44
-
45
- configManager.schemaOptions.useDefaults = false
46
-
47
- await configManager.parse(false, [], { validation: false, transform: false })
48
- config = configManager.current
49
-
50
- // If the schema is present, we use it to format the config
51
- if (configManager.schema) {
52
- const stringify = fjs(configManager.schema)
53
- config = JSON.parse(stringify(config))
54
- }
55
-
56
- const stringify = getStringifier(configManager.fullPath)
57
-
58
- const newConfig = stringify(config)
59
-
60
- await writeFile(configManager.fullPath, newConfig, 'utf8')
61
-
62
- logger.info(`✅ Updated ${configManager.fullPath}`)
63
- }