platformatic 2.0.0-alpha.5 → 2.0.0-alpha.6

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/cli.js CHANGED
@@ -13,7 +13,7 @@ import { join } from 'desm'
13
13
  import { isColorSupported } from 'colorette'
14
14
  import helpMe from 'help-me'
15
15
  import { upgrade } from './lib/upgrade.js'
16
- import { download } from './lib/download.js'
16
+ import { resolve } from './lib/resolve.js'
17
17
  import { logo } from './lib/ascii.js'
18
18
  import {
19
19
  runControl,
@@ -67,7 +67,7 @@ program.register('ps', async (args) => getRuntimesCommand(args))
67
67
  program.register('inject', async (args) => injectRuntimeCommand(args))
68
68
  program.register('logs', async (args) => streamRuntimeLogsCommand(args))
69
69
  program.register('upgrade', upgrade)
70
- program.register('download', download)
70
+ program.register('resolve', resolve)
71
71
  program.register('client', client)
72
72
  program.register('compile', async (args) => await compile(args) ? null : process.exit(1))
73
73
  program.register('help', help.toStdout)
@@ -1,18 +1,20 @@
1
- Download Platformatic Runtime external services
1
+ Resolve Platformatic Runtime external services
2
2
 
3
3
  ``` bash
4
- $ platformatic download
4
+ $ platformatic resolve
5
5
  ```
6
6
 
7
7
  Options:
8
8
 
9
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.
10
12
 
11
- Platformatic download command downloads runtime services that have the `url` in their configuration.
13
+ Platformatic resolve command resolves runtime services that have the `url` in their configuration.
12
14
  By default services are cloned with `git` to the `external` directory inside the runtime directory.
13
15
  To change the directory where a service is cloned, you can set the `path` property in the service configuration.
14
16
 
15
- After cloning the service, the download command will set the relative path to the service in the runtime configuration file.
17
+ After cloning the service, the resolve command will set the relative path to the service in the runtime configuration file.
16
18
 
17
19
  Example of the runtime platformatic.json configuration file:
18
20
 
@@ -8,14 +8,17 @@ import pretty from 'pino-pretty'
8
8
  import { execa } from 'execa'
9
9
  import fjs from 'fast-json-stringify'
10
10
 
11
- const DOWNLOAD_SERVICES_DIRNAME = 'external'
11
+ const RESOLVED_SERVICES_DIRNAME = 'external'
12
12
 
13
- export async function download (argv) {
13
+ export async function resolve (argv) {
14
14
  const args = parseArgs(argv, {
15
15
  alias: {
16
16
  config: 'c',
17
+ username: 'u',
18
+ password: 'p',
17
19
  },
18
20
  boolean: ['test'],
21
+ string: ['config', 'username', 'password'],
19
22
  default: { test: false },
20
23
  })
21
24
 
@@ -24,14 +27,18 @@ export async function download (argv) {
24
27
  ignore: 'hostname,pid',
25
28
  }))
26
29
  try {
27
- await downloadServices(args.config, logger, args.test)
30
+ await resolveServices(args.config, logger, {
31
+ test: args.test,
32
+ username: args.username,
33
+ password: args.password,
34
+ })
28
35
  } catch (err) {
29
36
  console.log(err)
30
37
  process.exit(1)
31
38
  }
32
39
  }
33
40
 
34
- async function downloadServices (config, logger, isTest = false) {
41
+ async function resolveServices (config, logger, options = {}) {
35
42
  const store = new Store({
36
43
  cwd: process.cwd(),
37
44
  logger,
@@ -58,10 +65,10 @@ async function downloadServices (config, logger, isTest = false) {
58
65
  }
59
66
 
60
67
  const projectDir = configManager.dirname
61
- const externalDir = join(projectDir, DOWNLOAD_SERVICES_DIRNAME)
68
+ const externalDir = join(projectDir, RESOLVED_SERVICES_DIRNAME)
62
69
 
63
70
  if (!config.services || config.services.length === 0) {
64
- logger.info('No external services to download')
71
+ logger.info('No external services to resolve')
65
72
  return
66
73
  }
67
74
 
@@ -86,13 +93,22 @@ async function downloadServices (config, logger, isTest = false) {
86
93
  const relativePath = relative(projectDir, path)
87
94
 
88
95
  logger.info(`Cloning ${service.url} into ${relativePath}`)
89
- if (!isTest) {
90
- await execa('git', ['clone', service.url, path])
96
+ if (!options.test) {
97
+ let url = service.url
98
+ if (options.username && options.password) {
99
+ const urlObj = new URL(service.url)
100
+ if (!urlObj.username && !urlObj.password) {
101
+ urlObj.username = options.username
102
+ urlObj.password = options.password
103
+ }
104
+ url = urlObj.href
105
+ }
106
+ await execa('git', ['clone', url, path])
91
107
  }
92
108
 
93
109
  // TODO: replace it with a proper runtime build step
94
- logger.info(`Downloading dependencies for service "${service.id}"`)
95
- if (!isTest) {
110
+ logger.info(`Resolving dependencies for service "${service.id}"`)
111
+ if (!options.test) {
96
112
  await execa('npm', ['i'], { cwd: path })
97
113
  }
98
114
 
@@ -107,7 +123,7 @@ async function downloadServices (config, logger, isTest = false) {
107
123
 
108
124
  await writeFile(configManager.fullPath, newConfig, 'utf8')
109
125
 
110
- logger.info('✅ All external services have been downloaded')
126
+ logger.info('✅ All external services have been resolved')
111
127
  }
112
128
 
113
129
  async function isDirectoryNotEmpty (directoryPath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "platformatic",
3
- "version": "2.0.0-alpha.5",
3
+ "version": "2.0.0-alpha.6",
4
4
  "description": "Platformatic CLI",
5
5
  "main": "cli.js",
6
6
  "type": "module",
@@ -37,9 +37,9 @@
37
37
  "neostandard": "^0.11.1",
38
38
  "split2": "^4.2.0",
39
39
  "typescript": "^5.5.3",
40
- "@platformatic/composer": "2.0.0-alpha.5",
41
- "@platformatic/service": "2.0.0-alpha.5",
42
- "@platformatic/db": "2.0.0-alpha.5"
40
+ "@platformatic/db": "2.0.0-alpha.6",
41
+ "@platformatic/composer": "2.0.0-alpha.6",
42
+ "@platformatic/service": "2.0.0-alpha.6"
43
43
  },
44
44
  "dependencies": {
45
45
  "@fastify/error": "^3.4.1",
@@ -56,14 +56,14 @@
56
56
  "pino": "^8.19.0",
57
57
  "pino-pretty": "^11.0.0",
58
58
  "undici": "^6.9.0",
59
- "@platformatic/client-cli": "2.0.0-alpha.5",
60
- "@platformatic/control": "2.0.0-alpha.5",
61
- "@platformatic/db": "2.0.0-alpha.5",
62
- "@platformatic/frontend-template": "2.0.0-alpha.5",
63
- "@platformatic/runtime": "2.0.0-alpha.5",
64
- "create-platformatic": "2.0.0-alpha.5",
65
- "@platformatic/utils": "2.0.0-alpha.5",
66
- "@platformatic/config": "2.0.0-alpha.5"
59
+ "@platformatic/client-cli": "2.0.0-alpha.6",
60
+ "@platformatic/config": "2.0.0-alpha.6",
61
+ "@platformatic/control": "2.0.0-alpha.6",
62
+ "@platformatic/db": "2.0.0-alpha.6",
63
+ "@platformatic/frontend-template": "2.0.0-alpha.6",
64
+ "@platformatic/utils": "2.0.0-alpha.6",
65
+ "create-platformatic": "2.0.0-alpha.6",
66
+ "@platformatic/runtime": "2.0.0-alpha.6"
67
67
  },
68
68
  "scripts": {
69
69
  "test": "pnpm run lint && borp --timeout=180000 --concurrency 1",