wattpm-utils 3.13.1 → 3.15.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/index.js CHANGED
@@ -10,9 +10,11 @@ import { version } from './lib/version.js'
10
10
  export async function main () {
11
11
  globalThis.platformatic = { executable: getExecutableId() }
12
12
 
13
- const logger = createCliLogger('info')
14
-
15
13
  const options = {
14
+ 'no-pretty': {
15
+ short: 'r',
16
+ type: 'boolean'
17
+ },
16
18
  verbose: {
17
19
  short: 'v',
18
20
  type: 'boolean'
@@ -28,6 +30,7 @@ export async function main () {
28
30
  }
29
31
 
30
32
  const { values, unparsed } = parseArgs(process.argv.slice(2), options)
33
+ const logger = createCliLogger('info', values['no-pretty'])
31
34
 
32
35
  if (values.version || unparsed[0] === 'version') {
33
36
  console.log(version)
@@ -23,6 +23,19 @@ import { installDependencies } from './dependencies.js'
23
23
 
24
24
  const originCandidates = ['origin', 'upstream']
25
25
 
26
+ function parseGitUrl (url) {
27
+ const fragmentIndex = url.indexOf('#')
28
+
29
+ if (fragmentIndex === -1) {
30
+ return { url, branch: null }
31
+ }
32
+
33
+ const baseUrl = url.substring(0, fragmentIndex)
34
+ const branch = url.substring(fragmentIndex + 1)
35
+
36
+ return { url: baseUrl, branch }
37
+ }
38
+
26
39
  async function parseLocalFolder (path) {
27
40
  // Read the package.json, if any
28
41
  const packageJsonPath = resolve(path, 'package.json')
@@ -256,7 +269,10 @@ async function importURL (logger, _, configurationFile, rawUrl, id, http, branch
256
269
  url = http ? `https://github.com/${rawUrl}.git` : `git@github.com:${rawUrl}.git`
257
270
  }
258
271
 
259
- await importApplication(logger, configurationFile, id ?? basename(rawUrl, '.git'), null, url, branch)
272
+ const parsed = parseGitUrl(url)
273
+ const effectiveBranch = branch ?? parsed.branch
274
+
275
+ await importApplication(logger, configurationFile, id ?? basename(parsed.url, '.git'), null, parsed.url, effectiveBranch)
260
276
  }
261
277
 
262
278
  async function importLocal (logger, root, configurationFile, path, overridenId) {
@@ -371,10 +387,12 @@ export async function resolveApplications (
371
387
  const absolutePath = application.path
372
388
  const relativePath = relative(root, absolutePath)
373
389
 
374
- // Clone and install dependencies
375
390
  childLogger.info(`Resolving application ${bold(application.id)} ...`)
376
391
 
377
- let url = application.url
392
+ const parsedGitUrl = parseGitUrl(application.url)
393
+ let url = parsedGitUrl.url
394
+ const effectiveBranch = application.gitBranch ?? parsedGitUrl.branch
395
+
378
396
  if (url.startsWith('http') && username && password) {
379
397
  const parsed = new URL(url)
380
398
  parsed.username ||= username
@@ -385,9 +403,9 @@ export async function resolveApplications (
385
403
  const cloneArgs = ['clone', url, absolutePath, '--single-branch', '--depth', 1]
386
404
 
387
405
  let branchLabel = ''
388
- if (application.gitBranch && application.gitBranch !== 'main') {
389
- cloneArgs.push('--branch', application.gitBranch)
390
- branchLabel = ` (branch ${bold(application.gitBranch)})`
406
+ if (effectiveBranch && effectiveBranch !== 'main') {
407
+ cloneArgs.push('--branch', effectiveBranch)
408
+ branchLabel = ` (branch ${bold(effectiveBranch)})`
391
409
  }
392
410
 
393
411
  if (username) {
@@ -583,7 +601,7 @@ export const help = {
583
601
  description: 'Do not install applications dependencies'
584
602
  },
585
603
  {
586
- usage: 'P, --package-manager <executable>',
604
+ usage: '-P, --package-manager <executable>',
587
605
  description: 'Use an alternative package manager (the default is to autodetect it)'
588
606
  }
589
607
  ]
@@ -615,7 +633,7 @@ export const help = {
615
633
  description: 'Do not install applications dependencies'
616
634
  },
617
635
  {
618
- usage: 'P, --package-manager <executable>',
636
+ usage: '-P, --package-manager <executable>',
619
637
  description: 'Use an alternative package manager (the default is to autodetect it)'
620
638
  }
621
639
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wattpm-utils",
3
- "version": "3.13.1",
3
+ "version": "3.15.0",
4
4
  "description": "The Node.js Application Server Utilities Commands",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -28,9 +28,9 @@
28
28
  "dotenv": "^16.4.5",
29
29
  "execa": "^9.4.0",
30
30
  "semver": "^7.7.0",
31
- "@platformatic/foundation": "3.13.1",
32
- "@platformatic/runtime": "3.13.1",
33
- "create-wattpm": "3.13.1"
31
+ "@platformatic/foundation": "3.15.0",
32
+ "@platformatic/runtime": "3.15.0",
33
+ "create-wattpm": "3.15.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "cleaner-spec-reporter": "^0.5.0",
@@ -40,7 +40,7 @@
40
40
  "neostandard": "^0.12.0",
41
41
  "typescript": "^5.5.4",
42
42
  "undici": "^7.0.0",
43
- "@platformatic/node": "3.13.1"
43
+ "@platformatic/node": "3.15.0"
44
44
  },
45
45
  "engines": {
46
46
  "node": ">=22.19.0"