@platformatic/generators 3.24.0-alpha0 → 3.25.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.
@@ -1,7 +1,7 @@
1
1
  import { findConfigurationFileRecursive, safeRemove } from '@platformatic/foundation'
2
2
  import { spawnSync } from 'node:child_process'
3
3
  import { readFile, readdir, stat } from 'node:fs/promises'
4
- import { dirname, join, relative, resolve } from 'node:path'
4
+ import { dirname, isAbsolute, join, relative, resolve } from 'node:path'
5
5
  import { BaseGenerator } from './base-generator.js'
6
6
 
7
7
  export class ImportGenerator extends BaseGenerator {
@@ -63,7 +63,12 @@ export class ImportGenerator extends BaseGenerator {
63
63
  }
64
64
 
65
65
  async _beforeWriteFiles (runtime) {
66
- const { module: pkg, version, applicationPath: path } = this.config
66
+ const { module: pkg, version } = this.config
67
+ let path = this.config.applicationPath
68
+
69
+ if (!isAbsolute(path)) {
70
+ path = resolve(this.runtime.targetDirectory, this.config.applicationPath)
71
+ }
67
72
 
68
73
  const packageJsonPath = join(path, 'package.json')
69
74
 
@@ -72,6 +77,8 @@ export class ImportGenerator extends BaseGenerator {
72
77
  await this.#generateConfigFile(path, '')
73
78
  await this.#updatePackageJson(packageJsonPath, 'package.json', pkg, version)
74
79
  } else {
80
+ this.config.pnpmWorkspacePath = path
81
+
75
82
  await this.#detectGitUrl(path)
76
83
  await this.#generateConfigFile(path, path)
77
84
 
@@ -94,7 +101,10 @@ export class ImportGenerator extends BaseGenerator {
94
101
  // Detect if there is a git folder and eventually get the remote
95
102
  for (const candidate of ['origin', 'upstream']) {
96
103
  try {
97
- const result = spawnSync('git', ['remote', 'get-url', candidate], { cwd: path })
104
+ const result = spawnSync('git', ['remote', 'get-url', candidate], {
105
+ cwd: path,
106
+ env: { GIT_DIR: join(path, '.git') }
107
+ })
98
108
 
99
109
  /* c8 ignore next 3 - Hard to test */
100
110
  if (result.error || result.status !== 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/generators",
3
- "version": "3.24.0-alpha0",
3
+ "version": "3.25.0",
4
4
  "description": "Main classes and utils for generators.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,7 +23,7 @@
23
23
  "fastify": "^5.0.0",
24
24
  "pino": "^9.9.0",
25
25
  "undici": "^7.0.0",
26
- "@platformatic/foundation": "3.24.0-alpha0"
26
+ "@platformatic/foundation": "3.25.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/inquirer": "^9.0.7",