@spark-ui/cli-utils 9.4.3 → 9.4.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/CHANGELOG.md +8 -0
- package/package.json +2 -3
- package/src/core/System.mjs +21 -11
- package/src/generate/generators/TemplateGenerator.mjs +6 -12
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [9.4.5](https://github.com/leboncoin/spark-web/compare/v9.4.4...v9.4.5) (2025-03-19)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @spark-ui/cli-utils
|
|
9
|
+
|
|
10
|
+
## [9.4.4](https://github.com/leboncoin/spark-web/compare/v9.4.3...v9.4.4) (2025-03-19)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @spark-ui/cli-utils
|
|
13
|
+
|
|
6
14
|
## [9.4.3](https://github.com/leboncoin/spark-web/compare/v9.4.2...v9.4.3) (2025-03-18)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @spark-ui/cli-utils
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spark-ui/cli-utils",
|
|
3
|
-
"version": "9.4.
|
|
3
|
+
"version": "9.4.5",
|
|
4
4
|
"description": "Spark CLI utils",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -38,12 +38,11 @@
|
|
|
38
38
|
"commander": "10.0.1",
|
|
39
39
|
"esbuild": "0.25.1",
|
|
40
40
|
"fs-extra": "11.3.0",
|
|
41
|
-
"glob": "8.1.0",
|
|
42
41
|
"pascal-case": "3.1.2",
|
|
43
42
|
"ts-morph": "22.0.0"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
45
|
"@types/fs-extra": "11.0.4"
|
|
47
46
|
},
|
|
48
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "17094b79c433fefb53e7cadb085ba3f6115a98d7"
|
|
49
48
|
}
|
package/src/core/System.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { mkdir, readFileSync, writeFile } from 'node:fs'
|
|
2
|
+
import { dirname } from 'node:path'
|
|
3
|
+
import { promisify } from 'node:util'
|
|
3
4
|
|
|
4
5
|
export class System {
|
|
5
6
|
logger
|
|
@@ -19,7 +20,7 @@ export class System {
|
|
|
19
20
|
|
|
20
21
|
getPackageJSON() {
|
|
21
22
|
const basePath = this.getBasePath()
|
|
22
|
-
const raw =
|
|
23
|
+
const raw = readFileSync(`${basePath}/package.json`).toString()
|
|
23
24
|
|
|
24
25
|
return JSON.parse(raw)
|
|
25
26
|
}
|
|
@@ -29,16 +30,25 @@ export class System {
|
|
|
29
30
|
const packageJSON = this.getPackageJSON()
|
|
30
31
|
|
|
31
32
|
return packageJSON.workspaces.some(workspace => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
try {
|
|
34
|
+
const packages = readFileSync(`${base}/${workspace}`, { withFileTypes: true })
|
|
35
|
+
.filter(dirent => dirent.isDirectory())
|
|
36
|
+
.map(dirent => `${base}/${workspace}/${dirent.name}/`)
|
|
37
|
+
|
|
38
|
+
return packages.some(path => path.endsWith(`/${name}/`))
|
|
39
|
+
} catch {
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
35
42
|
})
|
|
36
43
|
}
|
|
37
44
|
|
|
38
|
-
writeFile({ path, content }) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
async writeFile({ path, content }) {
|
|
46
|
+
try {
|
|
47
|
+
await promisify(mkdir)(dirname(path), { recursive: true })
|
|
48
|
+
await promisify(writeFile)(path, content)
|
|
49
|
+
this.logger.info(`Created ${path}`)
|
|
50
|
+
} catch {
|
|
51
|
+
this.exit(`Failed creating ${path}`)
|
|
52
|
+
}
|
|
43
53
|
}
|
|
44
54
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { readdir } from 'node:fs/promises'
|
|
2
|
+
import { join } from 'node:path'
|
|
1
3
|
import { fileURLToPath } from 'node:url'
|
|
2
4
|
|
|
3
5
|
import { camelCase } from 'camel-case'
|
|
4
|
-
import glob from 'glob'
|
|
5
6
|
import { pascalCase } from 'pascal-case'
|
|
6
7
|
|
|
7
8
|
import { Generator } from './Generator.mjs'
|
|
@@ -32,18 +33,11 @@ export class TemplateGenerator extends Generator {
|
|
|
32
33
|
return `${basePath}/packages/${context}/${name}`
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
getTemplatePaths({ type }) {
|
|
36
|
-
const
|
|
36
|
+
async getTemplatePaths({ type }) {
|
|
37
|
+
const templateDir = fileURLToPath(new URL(`../templates/${type}`, import.meta.url))
|
|
38
|
+
const files = await readdir(templateDir, { recursive: true })
|
|
37
39
|
|
|
38
|
-
return
|
|
39
|
-
glob(pattern, async (error, paths) => {
|
|
40
|
-
if (error) {
|
|
41
|
-
return reject(error)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
resolve(paths)
|
|
45
|
-
})
|
|
46
|
-
})
|
|
40
|
+
return files.filter(file => file.endsWith('.js')).map(file => join(templateDir, file))
|
|
47
41
|
}
|
|
48
42
|
|
|
49
43
|
getTemplatePath({ path, name, type, dest }) {
|