create-juisy 2.0.0-beta.13 → 2.0.0-beta.15
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 +27 -11
- package/package.json +57 -59
- package/template/CONTRIBUTING.md +41 -1
- package/template/bin/cli/cmds/private/test.js +14 -17
- package/template/dev.config.js +20 -0
- package/template/dev.config.ts +20 -0
- package/template/docs/readme/template.md +10 -1
- package/template/package.json +8 -3
- package/template/tests/unit/example.spec.ts +13 -0
- package/template/tests/unit/setup.unit.ts +14 -0
- package/template/tests/vitest.d.ts +16 -0
- package/template/tsconfig.json +18 -0
- package/template/vite.config.ts +22 -0
package/index.js
CHANGED
|
@@ -40,7 +40,10 @@ const argv = mri(process.argv.slice(2), {
|
|
|
40
40
|
const cwd = process.cwd()
|
|
41
41
|
|
|
42
42
|
// Get juisy version from this package.json file
|
|
43
|
-
const {
|
|
43
|
+
const {
|
|
44
|
+
version: JUISY_VERSION,
|
|
45
|
+
homepage: JUISY_DOCS_HOMEPAGE
|
|
46
|
+
} = JSON.parse(
|
|
44
47
|
fs.readFileSync(path.resolve(__dirname, './package.json'), 'utf-8')
|
|
45
48
|
)
|
|
46
49
|
|
|
@@ -107,15 +110,21 @@ async function main () {
|
|
|
107
110
|
'dev.config.json'
|
|
108
111
|
].filter(identifier => !identifier.endsWith(devConfigFormat)), // don't ignore dev config file of chosen format
|
|
109
112
|
logLevel: 'warn',
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
} else {
|
|
116
|
-
return content
|
|
113
|
+
templateData: (identifier) => {
|
|
114
|
+
return {
|
|
115
|
+
__PROJECT_NAME__: targetDir,
|
|
116
|
+
__JUISY_VERSION__: JUISY_VERSION,
|
|
117
|
+
__JUISY_DOCS_HOMEPAGE__: JUISY_DOCS_HOMEPAGE
|
|
117
118
|
}
|
|
118
119
|
}
|
|
120
|
+
// processor: (content, identifier) => {
|
|
121
|
+
// if (identifier === 'package.json') {
|
|
122
|
+
// let newContent = content.replace(/__PROJECT_NAME__/g, targetDir)
|
|
123
|
+
// return newContent
|
|
124
|
+
// } else {
|
|
125
|
+
// return content
|
|
126
|
+
// }
|
|
127
|
+
// }
|
|
119
128
|
})
|
|
120
129
|
|
|
121
130
|
substep($style.green(`✔ Successfuly copied`), { last: true })
|
|
@@ -141,12 +150,16 @@ async function main () {
|
|
|
141
150
|
'changelog': `${targetCliCommand} changelog`,
|
|
142
151
|
'git-hooks:reset': `${targetCliCommand} git-hooks reset`,
|
|
143
152
|
'git-hooks:sync': `${targetCliCommand} git-hooks sync`,
|
|
144
|
-
'test': `${targetCliCommand} test
|
|
153
|
+
'test': `${targetCliCommand} test run`,
|
|
154
|
+
'test:watch': `${targetCliCommand} test`,
|
|
155
|
+
'test:ui': 'npm run test:watch -- --ui --coverage.enabled=true',
|
|
156
|
+
'test:coverage': 'npm run test -- --coverage.enabled=true'
|
|
145
157
|
}
|
|
146
158
|
|
|
147
159
|
step('Adding scripts to package.json')
|
|
160
|
+
const packageJsonPath = path.join(path.resolve(cwd, targetDir), 'package.json')
|
|
148
161
|
const pkg = JSON.parse(
|
|
149
|
-
fs.readFileSync(
|
|
162
|
+
fs.readFileSync(packageJsonPath, 'utf-8')
|
|
150
163
|
)
|
|
151
164
|
pkg.scripts = pkg.scripts || {}
|
|
152
165
|
|
|
@@ -157,13 +170,16 @@ async function main () {
|
|
|
157
170
|
: true
|
|
158
171
|
const isLastStep = scriptName === Object.keys(scripts)[Object.keys(scripts).length - 1]
|
|
159
172
|
if (setScript) {
|
|
160
|
-
|
|
173
|
+
pkg.scripts[scriptName] = scripts[scriptName]
|
|
161
174
|
substep($style.green(`✔ Script "${scriptName}" successfuly added`), { last: isLastStep })
|
|
162
175
|
} else {
|
|
163
176
|
substep($style.yellow(`Script "${scriptName}" already set. Use --force option to overwrite`), { last: isLastStep })
|
|
164
177
|
}
|
|
165
178
|
}
|
|
166
179
|
|
|
180
|
+
// Replace package.json content
|
|
181
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(pkg, null, 2) + '\n')
|
|
182
|
+
|
|
167
183
|
log() // Blank line
|
|
168
184
|
log('You should now move into the created folder and run the following command:\n - npm install')
|
|
169
185
|
log() // Blank line
|
package/package.json
CHANGED
|
@@ -1,63 +1,61 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"devDependencies.juisy"
|
|
58
|
-
]
|
|
59
|
-
}
|
|
60
|
-
}
|
|
2
|
+
"name": "create-juisy",
|
|
3
|
+
"version": "2.0.0-beta.15",
|
|
4
|
+
"description": "Juisy boilerplate for npm init",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-juisy": "index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"template",
|
|
11
|
+
"index.js"
|
|
12
|
+
],
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"release": "release-it --no-increment",
|
|
18
|
+
"test": "echo No test found..."
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://gitlab.com/hperchec/juisy.git"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"js",
|
|
26
|
+
"build",
|
|
27
|
+
"release",
|
|
28
|
+
"changelog",
|
|
29
|
+
"bin",
|
|
30
|
+
"cmd",
|
|
31
|
+
"easy"
|
|
32
|
+
],
|
|
33
|
+
"author": {
|
|
34
|
+
"name": "Hervé Perchec",
|
|
35
|
+
"email": "contact@herve-perchec.com",
|
|
36
|
+
"url": "https://gitlab.com/herveperchec"
|
|
37
|
+
},
|
|
38
|
+
"license": "GPL-3.0-only",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://gitlab.com/hperchec/juisy/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://hperchec.gitlab.io/juisy",
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"execa": "^9.5.2",
|
|
45
|
+
"juisy": "2.0.0-beta.15",
|
|
46
|
+
"mri": "^1.2.0"
|
|
47
|
+
},
|
|
48
|
+
"release-it": {
|
|
49
|
+
"git": false,
|
|
50
|
+
"plugins": {
|
|
51
|
+
"@release-it/bumper": {
|
|
52
|
+
"out": {
|
|
53
|
+
"file": "package.json",
|
|
54
|
+
"path": [
|
|
55
|
+
"dependencies.juisy"
|
|
56
|
+
]
|
|
61
57
|
}
|
|
58
|
+
}
|
|
62
59
|
}
|
|
60
|
+
}
|
|
63
61
|
}
|
package/template/CONTRIBUTING.md
CHANGED
|
@@ -4,14 +4,54 @@
|
|
|
4
4
|
|
|
5
5
|
Commit messages are linted with `commitlint` in the `commit-msg` git hook, following the **angular** convention. Please check the [commit convention](./COMMIT_CONVENTION.md).
|
|
6
6
|
|
|
7
|
+
## Build
|
|
8
|
+
|
|
9
|
+
Write here the instructions to build your code, if needed.
|
|
10
|
+
|
|
11
|
+
To build, run the following command:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm run build
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Tests
|
|
18
|
+
|
|
19
|
+
### Units
|
|
20
|
+
|
|
21
|
+
To run unit tests, run the following command:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npm run test
|
|
25
|
+
# With coverage enabled
|
|
26
|
+
npm run test:coverage
|
|
27
|
+
# Watch mode
|
|
28
|
+
npm run test:watch
|
|
29
|
+
# With @vitest/ui
|
|
30
|
+
npm run test:ui
|
|
31
|
+
```
|
|
32
|
+
|
|
7
33
|
## Releases
|
|
8
34
|
|
|
9
35
|
Run the following command to make a release:
|
|
10
36
|
|
|
11
37
|
```sh
|
|
12
|
-
|
|
38
|
+
# Show help
|
|
39
|
+
npm run release --help
|
|
40
|
+
# Release a patch
|
|
41
|
+
npm run release --increment patch
|
|
42
|
+
# Release a specific version
|
|
43
|
+
npm run release -i 2.0.0
|
|
44
|
+
# To increment the current prerelease. For example:
|
|
45
|
+
# from 1.0.0-beta.1
|
|
46
|
+
# to 1.0.0-beta.2
|
|
47
|
+
npm run release -i pre
|
|
13
48
|
```
|
|
14
49
|
|
|
50
|
+
> 💡 See also:
|
|
51
|
+
>
|
|
52
|
+
> - the **juisy** [release tool documentation](<%= __JUISY_DOCS_HOMEPAGE__ %>)
|
|
53
|
+
> - the **release-it** [package documentation](https://github.com/release-it/release-it)
|
|
54
|
+
|
|
15
55
|
## Documentation
|
|
16
56
|
|
|
17
57
|
Run the following command to generate project documentation:
|
|
@@ -1,33 +1,30 @@
|
|
|
1
1
|
/** @type {import('juisy/cli').Command} */
|
|
2
2
|
export default new CLI.Command({
|
|
3
3
|
command: 'test',
|
|
4
|
-
describe: 'Run project tests',
|
|
4
|
+
describe: 'Run project tests with vitest. Accepts all arguments of vitest command.',
|
|
5
5
|
meta: {
|
|
6
6
|
private: true
|
|
7
7
|
},
|
|
8
8
|
builder (cli) {
|
|
9
|
-
cli.
|
|
10
|
-
alias: 'w',
|
|
11
|
-
type: 'boolean',
|
|
12
|
-
default: false,
|
|
13
|
-
describe: 'Run vitest in watch mode'
|
|
14
|
-
})
|
|
15
|
-
cli.option('ui', {
|
|
16
|
-
type: 'boolean',
|
|
17
|
-
default: false,
|
|
18
|
-
describe: 'Launch vitest UI'
|
|
19
|
-
})
|
|
9
|
+
cli.strict(false) // to forward all arguments
|
|
20
10
|
return cli
|
|
21
11
|
},
|
|
22
12
|
async handler (args) {
|
|
23
|
-
const watchMode = args.watch || args.ui
|
|
24
13
|
const { run } = CLI.InterfaceUtils
|
|
14
|
+
|
|
15
|
+
// Forward arguments to vitest command
|
|
16
|
+
const testCommandArgs = CLI.helpers.hideBin(process.argv).slice(1)
|
|
17
|
+
|
|
25
18
|
/**
|
|
26
19
|
* Run tests
|
|
27
20
|
*/
|
|
28
|
-
await run('
|
|
29
|
-
|
|
30
|
-
...
|
|
31
|
-
]
|
|
21
|
+
await run('npx', [
|
|
22
|
+
'vitest',
|
|
23
|
+
...testCommandArgs
|
|
24
|
+
])
|
|
25
|
+
// Prevent an error be thrown when Ctrl+C is pressed in watch mode
|
|
26
|
+
.catch((err) => {
|
|
27
|
+
if (err.exitCode !== 130) throw err
|
|
28
|
+
})
|
|
32
29
|
}
|
|
33
30
|
})
|
package/template/dev.config.js
CHANGED
|
@@ -42,5 +42,25 @@ export default {
|
|
|
42
42
|
'node ./bin/cli lint --fix'
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
|
+
},
|
|
46
|
+
release: {
|
|
47
|
+
/**
|
|
48
|
+
* See: https://github.com/release-it/release-it?tab=readme-ov-file#hooks
|
|
49
|
+
*/
|
|
50
|
+
hooks: {
|
|
51
|
+
'before:init': [
|
|
52
|
+
// Lint and run tests
|
|
53
|
+
'node ./bin/cli lint --fix',
|
|
54
|
+
'node ./bin/cli test'
|
|
55
|
+
],
|
|
56
|
+
'after:bump': [
|
|
57
|
+
// Build code and generate docs
|
|
58
|
+
'npm run build',
|
|
59
|
+
'node ./bin/cli docs generate:api',
|
|
60
|
+
'node ./bin/cli docs generate:readme',
|
|
61
|
+
'node ./bin/cli docs:cli:private',
|
|
62
|
+
'node ./bin/cli docs:cli:public'
|
|
63
|
+
]
|
|
64
|
+
}
|
|
45
65
|
}
|
|
46
66
|
}
|
package/template/dev.config.ts
CHANGED
|
@@ -43,5 +43,25 @@ export default {
|
|
|
43
43
|
'node ./bin/cli lint --fix'
|
|
44
44
|
]
|
|
45
45
|
}
|
|
46
|
+
},
|
|
47
|
+
release: {
|
|
48
|
+
/**
|
|
49
|
+
* See: https://github.com/release-it/release-it?tab=readme-ov-file#hooks
|
|
50
|
+
*/
|
|
51
|
+
hooks: {
|
|
52
|
+
'before:init': [
|
|
53
|
+
// Lint and run tests
|
|
54
|
+
'node ./bin/cli lint --fix',
|
|
55
|
+
'node ./bin/cli test'
|
|
56
|
+
],
|
|
57
|
+
'after:bump': [
|
|
58
|
+
// Build code and generate docs
|
|
59
|
+
'npm run build',
|
|
60
|
+
'node ./bin/cli docs generate:api',
|
|
61
|
+
'node ./bin/cli docs generate:readme',
|
|
62
|
+
'node ./bin/cli docs:cli:private',
|
|
63
|
+
'node ./bin/cli docs:cli:public'
|
|
64
|
+
]
|
|
65
|
+
}
|
|
46
66
|
}
|
|
47
67
|
} satisfies GlobalSettings
|
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
## Table of contents
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
<%%#
|
|
11
11
|
// Table of contents is automatically injected here by
|
|
12
12
|
// [remark-toc](https://github.com/remarkjs/remark-toc)
|
|
13
13
|
-%>
|
|
14
14
|
|
|
15
|
+
|
|
15
16
|
## 🚀 Get started
|
|
16
17
|
|
|
17
18
|
```sh
|
|
@@ -59,6 +60,10 @@ Read the [documentation](https://hperchec.gitlab.io/juisy) to learn more!
|
|
|
59
60
|
|
|
60
61
|
</details>
|
|
61
62
|
|
|
63
|
+
## 🤝 Contribute
|
|
64
|
+
|
|
65
|
+
See the [CONTRIBUTING.md](./CONTRIBUTING.md) file.
|
|
66
|
+
|
|
62
67
|
## ✍ Author
|
|
63
68
|
|
|
64
69
|
<%%= author %>
|
|
@@ -67,6 +72,10 @@ Read the [documentation](https://hperchec.gitlab.io/juisy) to learn more!
|
|
|
67
72
|
|
|
68
73
|
<%%= license %>
|
|
69
74
|
|
|
75
|
+
## 🧬 Changelog
|
|
76
|
+
|
|
77
|
+
See all changes to this project in the [CHANGELOG.md](./CHANGELOG.md) file.
|
|
78
|
+
|
|
70
79
|
----
|
|
71
80
|
|
|
72
81
|
Made with ❤ by <%%= author %>
|
package/template/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "__PROJECT_NAME__",
|
|
2
|
+
"name": "<%= __PROJECT_NAME__ %>",
|
|
3
3
|
"version": "1.0.0",
|
|
4
4
|
"description": "New project based on Juisy template",
|
|
5
5
|
"type": "module",
|
|
@@ -16,8 +16,13 @@
|
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://gitlab.com/hperchec/juisy/issues"
|
|
18
18
|
},
|
|
19
|
-
"homepage": "
|
|
19
|
+
"homepage": "<%= __JUISY_DOCS_HOMEPAGE__ %>",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"juisy": "
|
|
21
|
+
"juisy": "^<%= __JUISY_VERSION__ %>"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@vitest/coverage-v8": "^3",
|
|
25
|
+
"@vitest/ui": "^3",
|
|
26
|
+
"vitest": "^3"
|
|
22
27
|
}
|
|
23
28
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* See also Vitest documentation: https://vitest.dev/guide/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// ---------------------------------------------------
|
|
8
|
+
|
|
9
|
+
describe('Example test set', () => {
|
|
10
|
+
it('should return "foo"', () => {
|
|
11
|
+
expect('foo').toBe('foo')
|
|
12
|
+
})
|
|
13
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import 'vitest'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Here, you can augment types from vitest.
|
|
5
|
+
* For example to add custom matchers
|
|
6
|
+
* See also: https://vitest.dev/guide/extending-matchers.html#extending-matchers
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
interface CustomMatchers<R = unknown> {
|
|
10
|
+
toBeFoo: () => R
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare module 'vitest' {
|
|
14
|
+
interface Assertion<T = any> extends CustomMatchers<T> {}
|
|
15
|
+
interface AsymmetricMatchersContaining extends CustomMatchers {}
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "esnext",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"types": [
|
|
7
|
+
"vitest/globals",
|
|
8
|
+
"./tests/**/*.d.ts"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
"include": [
|
|
12
|
+
"tests/**/*.ts"
|
|
13
|
+
],
|
|
14
|
+
"exclude": [
|
|
15
|
+
"bin",
|
|
16
|
+
"node_modules"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="vitest" />
|
|
2
|
+
import { defineConfig } from 'vite'
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
test: {
|
|
6
|
+
setupFiles: [
|
|
7
|
+
'./tests/unit/setup.unit.ts'
|
|
8
|
+
],
|
|
9
|
+
include: [
|
|
10
|
+
'./tests/**/*.spec.ts'
|
|
11
|
+
],
|
|
12
|
+
coverage: {
|
|
13
|
+
enabled: true,
|
|
14
|
+
provider: 'v8',
|
|
15
|
+
reporter: [ 'text', 'json', 'html' ],
|
|
16
|
+
reportsDirectory: './tests/unit/.coverage',
|
|
17
|
+
include: [
|
|
18
|
+
// 'src/**'
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
})
|