@spark-ui/cli-utils 1.2.0 → 1.3.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 +10 -0
- package/bin/spark-setup-theme.mjs +47 -0
- package/bin/spark.mjs +1 -0
- package/package.json +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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
|
+
# [1.3.0](https://github.com/adevinta/spark/compare/@spark-ui/cli-utils@1.2.0...@spark-ui/cli-utils@1.3.0) (2023-02-20)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **cli-utils:** fix release ([e1c5ee0](https://github.com/adevinta/spark/commit/e1c5ee0923a2beaa8172be2c54c4cc4191ef13b7))
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- **cli-utils:** add new "spark setup-theme" cli command ([5b51126](https://github.com/adevinta/spark/commit/5b51126206ba0440d78f6429dcba3a7dd2f3af81)), closes [#253](https://github.com/adevinta/spark/issues/253)
|
|
15
|
+
|
|
6
16
|
# [1.2.0](https://github.com/adevinta/spark/compare/@spark-ui/cli-utils@1.1.1...@spark-ui/cli-utils@1.2.0) (2023-02-15)
|
|
7
17
|
|
|
8
18
|
### Features
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from 'child_process'
|
|
4
|
+
import { join, extname, parse, sep } from 'path'
|
|
5
|
+
import { readFileSync, readdirSync, writeFileSync, unlinkSync } from 'fs'
|
|
6
|
+
import { transformSync } from 'esbuild'
|
|
7
|
+
|
|
8
|
+
import { log, showError } from '../utils.js'
|
|
9
|
+
|
|
10
|
+
const jsFileExtension = '.js'
|
|
11
|
+
|
|
12
|
+
const configFile = readdirSync(process.cwd()).find(fileName =>
|
|
13
|
+
/^(spark\.theme\.config)\.(js|ts|mjs|mts|cjs|cts)$/.test(fileName)
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
if (!configFile) {
|
|
17
|
+
showError(
|
|
18
|
+
"We couldn't find a `spark.theme.config` file in this folder. Please make sure that the file is located in the root folder of your project"
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const configFileIsInJS = configFile === 'spark.theme.config.js'
|
|
23
|
+
const filePath = join(process.cwd(), configFile)
|
|
24
|
+
|
|
25
|
+
const allowedExtensions = ['.ts', '.mts', '.cts', '.js', '.cjs', '.mjs']
|
|
26
|
+
const fileExtension = extname(filePath)
|
|
27
|
+
if (!allowedExtensions.includes(fileExtension)) {
|
|
28
|
+
showError(`Your spark.theme.config file extension (${fileExtension}) is not supported.`)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const tsCode = readFileSync(filePath, 'utf-8')
|
|
32
|
+
const jsCode = transformSync(tsCode, { loader: 'ts' }).code
|
|
33
|
+
|
|
34
|
+
const jsFilePath = filePath.replace(/\.ts$|\.mts$|\.cts$|\.mjs|\.cjs$/, jsFileExtension)
|
|
35
|
+
const jsFileContents = Buffer.from(jsCode, 'utf-8')
|
|
36
|
+
|
|
37
|
+
if (!configFileIsInJS) writeFileSync(jsFilePath, jsFileContents)
|
|
38
|
+
|
|
39
|
+
const child = spawn(process.execPath, [jsFilePath], {
|
|
40
|
+
stdio: 'inherit',
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
child.on('exit', code => {
|
|
44
|
+
if (!configFileIsInJS) unlinkSync(jsFilePath)
|
|
45
|
+
log.success('✨ Your Spark theme config files have been successfully created!')
|
|
46
|
+
process.exit(code)
|
|
47
|
+
})
|
package/bin/spark.mjs
CHANGED
|
@@ -9,5 +9,6 @@ const { version } = require('../package.json')
|
|
|
9
9
|
program.version(version, '--version')
|
|
10
10
|
|
|
11
11
|
program.command('generate <component>', 'Generate a component scaffolding').alias('g')
|
|
12
|
+
program.command('setup-theme', 'Set up Spark theming configuration')
|
|
12
13
|
|
|
13
14
|
program.parse(process.argv)
|
package/package.json
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spark-ui/cli-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Spark CLI utils",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"bin": {
|
|
9
9
|
"spark": "./bin/spark.mjs",
|
|
10
|
-
"spark-generate": "./bin/spark-generate.mjs"
|
|
10
|
+
"spark-generate": "./bin/spark-generate.mjs",
|
|
11
|
+
"spark-setup-theme": "./bin/spark-setup-theme.mjs"
|
|
11
12
|
},
|
|
12
13
|
"type": "module",
|
|
13
|
-
"
|
|
14
|
-
"@clack/prompts": "
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@clack/prompts": "0.2.2",
|
|
15
16
|
"chalk": "5.2.0",
|
|
16
17
|
"commander": "10.0.0",
|
|
18
|
+
"esbuild": "0.17.8",
|
|
17
19
|
"fs-extra": "11.1.0",
|
|
18
20
|
"glob": "8.1.0",
|
|
19
21
|
"pascal-case": "3.1.2"
|
|
20
22
|
},
|
|
21
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "00159bc2201a7eb2e90f8292b377d0ad1df7f62a"
|
|
22
24
|
}
|