@spark-ui/cli-utils 2.14.0-beta.8 → 2.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/CHANGELOG.md +22 -0
- package/bin/spark-generate.mjs +1 -1
- package/package.json +3 -3
- package/src/core/Logger.mjs +1 -1
- package/src/scan/index.mjs +6 -9
- package/src/scan/loadConfig.mjs +5 -5
- package/test/spark-generate.test.ts +22 -29
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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
|
+
# [2.15.0](https://github.com/adevinta/spark/compare/@spark-ui/cli-utils@2.14.0...@spark-ui/cli-utils@2.15.0) (2024-07-03)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **cli-utils:** add some feedback when not loading a given config file ([1231fe6](https://github.com/adevinta/spark/commit/1231fe6cb94c15643a11278c3210836e81059364))
|
|
11
|
+
- **cli-utils:** fix config merge method to allow proper option override ([8b6a124](https://github.com/adevinta/spark/commit/8b6a124c6e70f05769305bf6ca84137c7a05510c))
|
|
12
|
+
- **cli-utils:** fix logger issue on generate script after changes ([083c9b0](https://github.com/adevinta/spark/commit/083c9b043d1837a807b159a8143fd16bf8d7087e))
|
|
13
|
+
- **cli-utils:** merge values ([a7e8129](https://github.com/adevinta/spark/commit/a7e81292d452d4ee026f3d4705198ac4ecc6363e))
|
|
14
|
+
- **cli-utils:** merging configs ([aeb6251](https://github.com/adevinta/spark/commit/aeb6251d23bc506674e4545ebad928081292f520))
|
|
15
|
+
- **cli-utils:** missalignment on the default config values nesting ([79729f7](https://github.com/adevinta/spark/commit/79729f722f4ecf6f0c671e2c1c1d5929a87d98c9))
|
|
16
|
+
- **cli-utils:** output file creates new content ([973ffa8](https://github.com/adevinta/spark/commit/973ffa85e6987dbd87a119e9253db57556a705d4))
|
|
17
|
+
- **cli-utils:** remove betta tagging ([96cafae](https://github.com/adevinta/spark/commit/96cafae45e4a4759ef9ff4a763963f26cb898cb6))
|
|
18
|
+
- **cli-utils:** remove extra logs ([f588649](https://github.com/adevinta/spark/commit/f588649eb299fc42ef9d6dbf8f8f4eebd0cfd6a9))
|
|
19
|
+
- **cli-utils:** remove unnecesary log ([614d834](https://github.com/adevinta/spark/commit/614d834d5d7a0f3084b3097e2dee5436b369fbb6))
|
|
20
|
+
- log config setted ([190a058](https://github.com/adevinta/spark/commit/190a0581ab6219591c5d3a3ecde2ee46d504d7ca))
|
|
21
|
+
- priority of commands ([ed178a5](https://github.com/adevinta/spark/commit/ed178a51a8cea0255c96467b0d8760daf8f851dd))
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
- **cli-utils:** exoposes all configuration parameters as a build argument ([3e88a99](https://github.com/adevinta/spark/commit/3e88a998c05da026cd196b3dd54a2ad50506266c))
|
|
26
|
+
- mixing parameters ([da1bf1d](https://github.com/adevinta/spark/commit/da1bf1d838df2c577755eb3c651cd0bba8d07203))
|
|
27
|
+
|
|
6
28
|
# [2.14.0](https://github.com/adevinta/spark/compare/@spark-ui/cli-utils@2.13.8...@spark-ui/cli-utils@2.14.0) (2024-06-14)
|
|
7
29
|
|
|
8
30
|
### Features
|
package/bin/spark-generate.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { TemplateGenerator } from '../src/generate/generators/index.mjs'
|
|
|
6
6
|
import { Logger, System } from '../src/core/index.mjs'
|
|
7
7
|
import { DescriptionValidator, NameValidator } from '../src/generate/validators/index.mjs'
|
|
8
8
|
|
|
9
|
-
const logger = new Logger()
|
|
9
|
+
const logger = new Logger({ verbose: true })
|
|
10
10
|
const system = new System({ logger })
|
|
11
11
|
const generator = new TemplateGenerator({ system })
|
|
12
12
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spark-ui/cli-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0",
|
|
4
4
|
"description": "Spark CLI utils",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"esbuild": "0.21.5",
|
|
40
40
|
"fs-extra": "11.2.0",
|
|
41
41
|
"glob": "8.1.0",
|
|
42
|
-
"lodash.merge": "4.6.2",
|
|
43
42
|
"pascal-case": "3.1.2",
|
|
44
43
|
"ts-morph": "22.0.0"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@types/fs-extra": "11.0.4"
|
|
48
|
-
}
|
|
47
|
+
},
|
|
48
|
+
"gitHead": "8a312bf6a9f20c8dd0cc3cc10649359c4313a2a7"
|
|
49
49
|
}
|
package/src/core/Logger.mjs
CHANGED
package/src/scan/index.mjs
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import * as process from 'node:process'
|
|
4
4
|
|
|
5
5
|
import { existsSync, mkdirSync, writeFileSync } from 'fs'
|
|
6
|
-
import merge from 'lodash.merge'
|
|
7
6
|
import path from 'path'
|
|
8
7
|
|
|
9
8
|
import { Logger } from '../core/index.mjs'
|
|
@@ -19,14 +18,12 @@ export async function adoption(options = {}) {
|
|
|
19
18
|
let config = await loadConfig(configuration, { logger })
|
|
20
19
|
|
|
21
20
|
config = {
|
|
22
|
-
adoption:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
),
|
|
21
|
+
adoption: {
|
|
22
|
+
...config.adoption,
|
|
23
|
+
...optionsConfig,
|
|
24
|
+
imports: optionsConfig.imports || config.adoption.imports,
|
|
25
|
+
extensions: optionsConfig.extensions || config.adoption.extensions,
|
|
26
|
+
},
|
|
30
27
|
}
|
|
31
28
|
|
|
32
29
|
let importCount = 0
|
package/src/scan/loadConfig.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
2
|
|
|
3
3
|
import { existsSync } from 'fs'
|
|
4
|
-
import merge from 'lodash.merge'
|
|
5
4
|
import path from 'path'
|
|
6
5
|
|
|
7
6
|
import * as defaultConfig from './config.mjs'
|
|
@@ -14,11 +13,12 @@ export async function loadConfig(configuration, { logger }) {
|
|
|
14
13
|
const { default: customConfig } = await import(configFileRoute)
|
|
15
14
|
|
|
16
15
|
const config = {
|
|
17
|
-
adoption:
|
|
16
|
+
adoption: {
|
|
17
|
+
...defaultConfig,
|
|
18
18
|
...customConfig.adoption,
|
|
19
|
-
imports: customConfig.imports || defaultConfig.imports,
|
|
20
|
-
extensions: customConfig.extensions || defaultConfig.extensions,
|
|
21
|
-
}
|
|
19
|
+
imports: customConfig.adoption.imports || defaultConfig.imports,
|
|
20
|
+
extensions: customConfig.adoption.extensions || defaultConfig.extensions,
|
|
21
|
+
},
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
return config
|
|
@@ -12,21 +12,28 @@ const cliPath = path.join(__dirname, '../../bin/spark.mjs')
|
|
|
12
12
|
const cliProcess = cmd.create(cliPath)
|
|
13
13
|
|
|
14
14
|
describe('CLI `spark generate` (component package)', () => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const packageType = 'component'
|
|
16
|
+
|
|
17
|
+
const contextPath = TemplateGenerator.CONTEXTS[packageType] as string
|
|
18
|
+
|
|
19
|
+
const packagePath = path.join(process.cwd(), 'packages', contextPath, 'bar')
|
|
20
|
+
const invalidPackagePath = path.join(process.cwd(), 'packages', contextPath, '123')
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
if (fse.existsSync(packagePath)) fse.removeSync(packagePath)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
afterAll(() => {
|
|
27
|
+
if (fse.existsSync(packagePath)) fse.removeSync(packagePath)
|
|
28
|
+
})
|
|
19
29
|
|
|
20
|
-
|
|
30
|
+
it('should properly generate package from CLI when arguments are valid', async () => {
|
|
21
31
|
const response = await cliProcess.execute(
|
|
22
32
|
['generate'],
|
|
23
|
-
[
|
|
33
|
+
['bar', ENTER, packageType, ENTER, 'This is my foo component', ENTER]
|
|
24
34
|
)
|
|
25
|
-
const contextPath = TemplateGenerator.CONTEXTS[packageType] as string
|
|
26
|
-
const packagePath = path.join(process.cwd(), 'packages', contextPath, packageName)
|
|
27
35
|
|
|
28
|
-
|
|
29
|
-
const expectedFiles = [
|
|
36
|
+
;[
|
|
30
37
|
'/.npmignore',
|
|
31
38
|
'/package.json',
|
|
32
39
|
'/src/index.ts',
|
|
@@ -37,33 +44,19 @@ describe('CLI `spark generate` (component package)', () => {
|
|
|
37
44
|
'/src/Bar.test.tsx',
|
|
38
45
|
'/src/Bar.stories.tsx',
|
|
39
46
|
'/tsconfig.json',
|
|
40
|
-
]
|
|
41
|
-
|
|
42
|
-
const assertExpectedFiles = (filePath: string) => {
|
|
47
|
+
].forEach((filePath: string) => {
|
|
43
48
|
expect(response).toContain(`Created ${packagePath}${filePath}`)
|
|
44
49
|
expect(fse.pathExistsSync(`${packagePath}${filePath}`)).toBe(true)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
expectedFiles.forEach(assertExpectedFiles)
|
|
48
|
-
|
|
49
|
-
// Finally we clean up the generated component package
|
|
50
|
-
fse.removeSync(packagePath)
|
|
50
|
+
})
|
|
51
51
|
})
|
|
52
52
|
|
|
53
53
|
it('should prevent generating package when argument are invalid', async () => {
|
|
54
|
-
|
|
55
|
-
const packageName = '123'
|
|
56
|
-
const packageType = 'component'
|
|
57
|
-
|
|
58
|
-
// WHEN we try to create it
|
|
59
|
-
const response = await cliProcess.execute(['generate'], [packageName, ENTER])
|
|
60
|
-
const contextPath = TemplateGenerator.CONTEXTS[packageType] as string
|
|
61
|
-
const packagePath = path.join(process.cwd(), 'packages', contextPath, packageName)
|
|
54
|
+
const response = await cliProcess.execute(['generate'], ['123', ENTER])
|
|
62
55
|
|
|
63
|
-
// THEN it throws an error and fails to create files for this package
|
|
64
56
|
expect(response).toContain(
|
|
65
57
|
'Name name must contain letters and dash symbols only (ex: "my-package")'
|
|
66
58
|
)
|
|
67
|
-
|
|
59
|
+
|
|
60
|
+
expect(fse.pathExistsSync(invalidPackagePath)).toBe(false)
|
|
68
61
|
})
|
|
69
62
|
})
|