Compare commits
35 Commits
v2.0.2-pre
...
v2.0.0-pre
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62a89fb127 | ||
| c219d382e6 | |||
| 90ba9f72f2 | |||
| 09d330af63 | |||
|
|
f38ca060de | ||
|
|
41e85b824d | ||
| 6553fbef95 | |||
|
|
add794a7db | ||
| d4cb767484 | |||
| 570b00d01b | |||
| 7ef34210a5 | |||
| b6fed83c91 | |||
| e0c0f5c1ce | |||
| 5cf569262c | |||
| 29a7aa3971 | |||
| b4f0731345 | |||
| e66d6ba86a | |||
| 96c1d5a759 | |||
| f25cda738b | |||
| 995b43380f | |||
| 4821be6a00 | |||
| f59111f1fe | |||
| 8478d36ec1 | |||
| f0a080cadc | |||
| c95477d02b | |||
| a955c4da0d | |||
| 17fdf0c4a6 | |||
| 22ad5d4c75 | |||
| b2373aa5fa | |||
| 3b0fc7a8c1 | |||
| 0bb282c7b6 | |||
| b57be8ed66 | |||
| 55877f0bcd | |||
| 9830df8bd7 | |||
| d168dc1988 |
2
.github/workflows/release.yml
vendored
@@ -31,6 +31,8 @@ jobs:
|
||||
run: pnpm test
|
||||
- name: Build Package
|
||||
run: pnpm build
|
||||
- name: Pack
|
||||
run: cd ./dist && pnpm pack --pack-destination=../
|
||||
- name: Semantic Release
|
||||
run: npx semantic-release
|
||||
env:
|
||||
|
||||
16
CHANGELOG.md
@@ -1,21 +1,21 @@
|
||||
# Change Log
|
||||
|
||||
## [2.0.1](https://github.com/chenasraf/simple-scaffold/compare/v2.0.0...v2.0.1) (2024-02-02)
|
||||
# [2.0.0-pre.3](https://github.com/chenasraf/simple-scaffold/compare/v2.0.0-pre.2...v2.0.0-pre.3) (2024-01-30)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* log level flag ([5d7f449](https://github.com/chenasraf/simple-scaffold/commit/5d7f449050e50a6e4b2d00b7a2215cdb5fc9b611))
|
||||
* rm tmp dir too early ([4aa52c8](https://github.com/chenasraf/simple-scaffold/commit/4aa52c84bd8cf302031e9f7f6407466aa736beb7))
|
||||
* tests ([c219d38](https://github.com/chenasraf/simple-scaffold/commit/c219d382e6df8b2ca1157544a7785f6645d04be2))
|
||||
|
||||
# [2.0.0](https://github.com/chenasraf/simple-scaffold/compare/v1.9.0...v2.0.0) (2024-01-31)
|
||||
## 2.0.0-pre.2 (2024-01-29)
|
||||
|
||||
* fix!: version number ([bc0a18d](https://github.com/chenasraf/simple-scaffold/commit/bc0a18dce01fefec6187192cb20c9303f7f7dbfa))
|
||||
* remove gh flag ([939200c](https://github.com/chenasraf/simple-scaffold/commit/939200c9f21be240485ea602a73b983ba2f47aaf))
|
||||
* tests ([ff92fd7](https://github.com/chenasraf/simple-scaffold/commit/ff92fd7607f1b86f36fc6b62652fdfc81cb391a3))
|
||||
* try multiple default config files ([89aacb5](https://github.com/chenasraf/simple-scaffold/commit/89aacb58fd90a892f4994c758c61c43b2a6b1fba))
|
||||
* Update README.md ([e012d51](https://github.com/chenasraf/simple-scaffold/commit/e012d51))
|
||||
* docs: fix readme doc links ([55e561b](https://github.com/chenasraf/simple-scaffold/commit/55e561b))
|
||||
|
||||
|
||||
|
||||
## 2.0.0-pre.1 (2024-01-29)
|
||||
|
||||
* chore: fix docs & formatting ([b4f0731](https://github.com/chenasraf/simple-scaffold/commit/b4f0731))
|
||||
* chore: update deps ([22ad5d4](https://github.com/chenasraf/simple-scaffold/commit/22ad5d4))
|
||||
* chore: update deps ([b2373aa](https://github.com/chenasraf/simple-scaffold/commit/b2373aa))
|
||||
|
||||
198
README.md
@@ -1,6 +1,4 @@
|
||||
<p align="center">
|
||||
<img src="https://chenasraf.github.io//simple-scaffold/img/logo-lg.png" alt="Logo" />
|
||||
</p>
|
||||
<h1 align="center">Simple Scaffold</h1>
|
||||
|
||||
<h2 align="center">
|
||||
|
||||
@@ -8,7 +6,7 @@
|
||||
[Documentation](https://chenasraf.github.io/simple-scaffold) |
|
||||
[NPM](https://npmjs.com/package/simple-scaffold) | [casraf.dev](https://casraf.dev)
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
</h2>
|
||||
@@ -27,82 +25,60 @@ lifting for you and start building your projects faster and more efficiently tod
|
||||
|
||||
<div align="center">
|
||||
|
||||

|
||||

|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
## Documentation
|
||||
## Quick Start
|
||||
|
||||
See full documentation [here](https://chenasraf.github.io/simple-scaffold).
|
||||
### Local Templates
|
||||
|
||||
- [Command Line Interface (CLI) usage](https://chenasraf.github.io/simple-scaffold/docs/usage/cli)
|
||||
- [Node.js usage](https://chenasraf.github.io/simple-scaffold/docs/usage/node)
|
||||
- [Templates](https://chenasraf.github.io/simple-scaffold/docs/usage/templates)
|
||||
- [Configuration Files](https://chenasraf.github.io/simple-scaffold/docs/usage/configuration_files)
|
||||
- [Migration](https://chenasraf.github.io/simple-scaffold/docs/usage/migration)
|
||||
The fastest way to get started is to use `npx` to immediately start a scaffold process.
|
||||
|
||||
## Getting Started
|
||||
Prepare any templates you want to use - for example, in the directory `templates/component`; and use
|
||||
that in the CLI args. Here is a simple example file:
|
||||
|
||||
### Cheat Sheet
|
||||
Simple Scaffold will maintain any file and directory structure you try to generate.
|
||||
|
||||
A quick rundown of common usage scenarios:
|
||||
`templates/component/{{ pascalName name }}.tsx`
|
||||
|
||||
- Remote template config file on GitHub:
|
||||
```tsx
|
||||
// Created: {{ now 'yyyy-MM-dd' }}
|
||||
import React from 'react'
|
||||
|
||||
```sh
|
||||
npx simple-scaffold -g username/repository -c scaffold.js -k component NewComponentName
|
||||
```
|
||||
|
||||
- Local template config file:
|
||||
|
||||
```sh
|
||||
npx simple-scaffold -c scaffold.js -k component NewComponentName
|
||||
```
|
||||
|
||||
- Local one-time usage:
|
||||
|
||||
```sh
|
||||
npx simple-scaffold -t templates/component -o src/components NewComponentName
|
||||
```
|
||||
|
||||
### Remote Configurations
|
||||
|
||||
The fastest way to get started is to is to re-use someone else's (or your own) work using a template
|
||||
repository.
|
||||
|
||||
A remote config can be loaded in one of these ways:
|
||||
|
||||
- For templates hosted on GitHub, the syntax is `-g user/repository_name`
|
||||
- For other Git platforms like GitLab, use `-g https://example.com/user/repository_name.git`
|
||||
|
||||
These remote configurations support multiple scaffold groups, which can be specified using the
|
||||
`--key` or `-k` argument:
|
||||
|
||||
```sh
|
||||
$ npx simple-scaffold \
|
||||
-g chenasraf/simple-scaffold \
|
||||
-k component \
|
||||
PageWrapper
|
||||
|
||||
# equivalent to:
|
||||
$ npx simple-scaffold \
|
||||
-g https://github.com/chenasraf/simple-scaffold.git \
|
||||
-c scaffold.config.js \
|
||||
-k component \
|
||||
PageWrapper
|
||||
export default {{pascalCase name}}: React.FC = (props) => {
|
||||
return (
|
||||
<div className="{{camelCase name}}">{{pascalCase name}} Component</div>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
By default, the template name is set to `default` when the `--key` option is not provided.
|
||||
To generate the template output, run:
|
||||
|
||||
See information about each option and flag using the `--help` flag, or read the
|
||||
[CLI documentation](https://chenasraf.github.io/simple-scaffold/docs/usage/cli). For information
|
||||
about how configuration files work, [see below](#configuration-files).
|
||||
```sh
|
||||
# generate single component
|
||||
$ npx simple-scaffold@latest \
|
||||
-t templates/component -o src/components PageWrapper
|
||||
```
|
||||
|
||||
This will immediately create the following file: `src/components/PageWrapper.tsx`
|
||||
|
||||
```tsx
|
||||
// Created: 2077-01-01
|
||||
import React from 'react'
|
||||
|
||||
export default PageWrapper: React.FC = (props) => {
|
||||
return (
|
||||
<div className="pageWrapper">PageWrapper Component</div>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
### Configuration Files
|
||||
|
||||
You can use a config file to more easily maintain all your scaffold definitions.
|
||||
You can also use a config file to more easily maintain all your scaffold definitions.
|
||||
|
||||
`scaffold.config.js`
|
||||
|
||||
@@ -123,61 +99,66 @@ module.exports = {
|
||||
Then call your scaffold like this:
|
||||
|
||||
```sh
|
||||
$ npx simple-scaffold -c scaffold.config.js PageWrapper
|
||||
$ npx simple-scaffold@latest -c scaffold.config.js PageWrapper
|
||||
```
|
||||
|
||||
This will allow you to avoid needing to remember which configs are needed or to store them in a
|
||||
one-liner in `package.json` which can get pretty long and messy, and harder to maintain.
|
||||
1-liner in `packqge.json` which can get pretty long and messy, which is harder to maintain.
|
||||
|
||||
Also, this allows you to define more complex scaffolds with logic without having to use the Node.js
|
||||
API directly. (Of course you always have the option to still do so if you wish)
|
||||
|
||||
More information can be found at the
|
||||
[Configuration Files documentation](https://chenasraf.github.io/simple-scaffold/docs/usage/configuration_files).
|
||||
See more at the [CLI documentation](https://chenasraf.github.io/simple-scaffold/docs/usage/cli) and
|
||||
[Configuration Files](https://chenasraf.github.io/simple-scaffold/docs/usage/configuration_files).
|
||||
|
||||
### Templates Structure
|
||||
### Remote Configurations
|
||||
|
||||
Templates are **any file** in the a directory given to `--templates`.
|
||||
Another quick way to start is to re-use someone else's (or your own) work using a template
|
||||
repository.
|
||||
|
||||
Simple Scaffold will maintain any file and directory structure you try to generate, while replacing
|
||||
any tokens such as `{{ name }}` or other custom-data using
|
||||
[Handlebars.js](https://handlebarsjs.com/).
|
||||
A remote config can be loaded in one of these ways:
|
||||
|
||||
`templates/component/{{ pascalName name }}.tsx`
|
||||
- If it's on GitHub, you can use `-g user/repository_name`
|
||||
- If it's on another git server (such as GitLab), you can use
|
||||
`-g https://example.com/user/repository_name.git`
|
||||
|
||||
```tsx
|
||||
// Created: {{ now 'yyyy-MM-dd' }}
|
||||
import React from 'react'
|
||||
|
||||
export default {{pascalCase name}}: React.FC = (props) => {
|
||||
return (
|
||||
<div className="{{camelCase name}}">{{pascalCase name}} Component</div>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
To generate the template output once without saving a configuration file, run:
|
||||
Configurations can hold multiple scaffold groups. Each group can be accessed using its key by
|
||||
supplying the `--key` or `-k` argument, like so:
|
||||
|
||||
```sh
|
||||
# generate single component
|
||||
$ npx simple-scaffold \
|
||||
-t templates/component \
|
||||
-o src/components \
|
||||
-g user/repository_name -c scaffold.js -k key_name`.
|
||||
```
|
||||
|
||||
Here is an example for loading the example component templates in this very repository:
|
||||
|
||||
```sh
|
||||
$ npx simple-scaffold@latest \
|
||||
-g chenasraf/simple-scaffold \
|
||||
-k component \
|
||||
PageWrapper
|
||||
|
||||
# equivalent to:
|
||||
$ npx simple-scaffold@latest \
|
||||
-g https://github.com/chenasraf/simple-scaffold.git \
|
||||
-c scaffold.config.js \
|
||||
-k component \
|
||||
PageWrapper
|
||||
```
|
||||
|
||||
This will immediately create the following file: `src/components/PageWrapper.tsx`
|
||||
When template name (`-k component`) is omitted, `default` is used.
|
||||
|
||||
```tsx
|
||||
// Created: 2077-01-01
|
||||
import React from 'react'
|
||||
See more at the [CLI documentation](https://chenasraf.github.io/simple-scaffold/docs/usage/cli) and
|
||||
[Configuration Files](https://chenasraf.github.io/simple-scaffold/docs/usage/configuration_files).
|
||||
|
||||
export default PageWrapper: React.FC = (props) => {
|
||||
return (
|
||||
<div className="pageWrapper">PageWrapper Component</div>
|
||||
)
|
||||
}
|
||||
```
|
||||
## Documentation
|
||||
|
||||
See full documentation [here](https://chenasraf.github.io/simple-scaffold).
|
||||
|
||||
- [Command Line Interface (CLI) usage](https://chenasraf.github.io/simple-scaffold/docs/usage/cli)
|
||||
- [Node.js usage](https://chenasraf.github.io/simple-scaffold/docs/usage/node)
|
||||
- [Templates](https://chenasraf.github.io/simple-scaffold/docs/usage/templates)
|
||||
- [Configuration Files](https://chenasraf.github.io/simple-scaffold/docs/usage/configuration_files)
|
||||
- [Migration](https://chenasraf.github.io/simple-scaffold/docs/usage/migration)
|
||||
|
||||
## Contributing
|
||||
|
||||
@@ -208,9 +189,22 @@ If you are a developer and want to contribute code, here are some starting tips:
|
||||
|
||||
Some tips on getting around the code:
|
||||
|
||||
- Use `pnpm dev` for development - it runs TypeScript compile in watch mode, allowing you to make
|
||||
changes and immediately be able to try them using `pnpm cmd`.
|
||||
- Use `pnpm build` to build the output once
|
||||
- Use `pnpm test` to run tests
|
||||
- Use `pnpm cmd` to use the CLI feature of Simple Scaffold from within the root directory, enabling
|
||||
you to test different behaviors. See `pnpm cmd -h` for more information.
|
||||
- Use `pnpm test` to run tests
|
||||
- Use `pnpm docs:build` to build the documentation once
|
||||
- Use `pnpm docs:watch` to start docs in watch mode
|
||||
- Use `pnpm build` to build the output
|
||||
|
||||
> This requires an updated build, and does not trigger one itself. From here you have several
|
||||
> options:
|
||||
>
|
||||
> - Run `pnpm dev` to watch for file changes and build automatically
|
||||
> - Run `pnpm build` before running this to trigger a one-time build
|
||||
> - Run `pnpm build-cmd` which triggers a build right before running `pnpm cmd` automatically with
|
||||
> the rest of the given arguments.
|
||||
|
||||
- Use `pnpm build-docs` to build the documentation once
|
||||
- Use `pnpm watch-docs` to start docs in watch mode
|
||||
- To see the documentation, currently you have to serve the directory yourself with a static web
|
||||
server (like node's built in serve, VS code's "Go Live" mode, etc)
|
||||
|
||||
@@ -28,7 +28,6 @@ To see this and more information anytime, add the `-h` or `--help` flag to your
|
||||
| `--log-level` \| `-l` | Determine amount of logs to display. The values are: `none \| debug \| info \| warn \| error`. The provided level will display messages of the same level or higher. |
|
||||
| `--dry-run` \| `-dr` | Don't emit files. This is good for testing your scaffolds and making sure they don't fail, without having to write actual file contents or create directories. |
|
||||
| `--help` \| `-h` | Show this help message |
|
||||
| `--version` \| `-v` | Display version. |
|
||||
|
||||
## Examples:
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ title: Usage
|
||||
---
|
||||
|
||||
- [CLI Usage](cli)
|
||||
- [Configuration Files](configuration_files)
|
||||
- [Configuration Files](configuation_files)
|
||||
- [Examples](examples)
|
||||
- [Migration](migration)
|
||||
- [Node.js Usage](node)
|
||||
|
||||
@@ -15,7 +15,8 @@ title: Migration
|
||||
- The `#template_file` syntax has been removed, you may use `--config` or `-c` to tell Simple
|
||||
Scaffold which file to look for inside the git project. There is a default file priority list
|
||||
which can find the file for you if it is in one of the supported filenames.
|
||||
- `verbose` can now take the names `debug`, `info`, `warn`, `error` or `none` (case insensitive).
|
||||
- `verbose` can now take the names `debug`, `info`, `warn`, `error` or `none` (case insensitive) or
|
||||
as usual by using the numbering from before.
|
||||
- `--create-sub-folder` (`-s`) has been renamed to `--subdir` (`-s`) in the CLI. The Node.js names
|
||||
have been changed as well.
|
||||
- `--sub-folder-name-helper` (`-sh`) has been renamed to `--subdir-helper` (`-sh`). The Node.js
|
||||
|
||||
@@ -5,7 +5,7 @@ import type * as Preset from "@docusaurus/preset-classic"
|
||||
const config: Config = {
|
||||
title: "Simple Scaffold",
|
||||
tagline: "Generate any file structure - from single components to entire app boilerplates, with a single command.",
|
||||
favicon: "img/favicon.svg",
|
||||
favicon: "img/favicon.ico",
|
||||
|
||||
// Set the production url of your site here
|
||||
url: "https://chenasraf.github.io",
|
||||
@@ -64,7 +64,13 @@ const config: Config = {
|
||||
sidebarPath: "./sidebars.ts",
|
||||
// Please change this to your repo.
|
||||
// Remove this to remove the "edit this page" links.
|
||||
editUrl: "https://github.com/chenasraf/simple-scaffold/blob/master/docs",
|
||||
editUrl: "https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/",
|
||||
},
|
||||
blog: {
|
||||
showReadingTime: true,
|
||||
// Please change this to your repo.
|
||||
// Remove this to remove the "edit this page" links.
|
||||
editUrl: "https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/",
|
||||
},
|
||||
theme: {
|
||||
customCss: "./src/css/custom.css",
|
||||
@@ -121,7 +127,7 @@ const config: Config = {
|
||||
position: "right",
|
||||
},
|
||||
{
|
||||
href: "https://github.com/chenasraf/simple-scaffold",
|
||||
href: "https://github.com/facebook/docusaurus",
|
||||
label: "GitHub",
|
||||
position: "right",
|
||||
},
|
||||
|
||||
@@ -22,13 +22,3 @@
|
||||
justify-content: center;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
.heroImage {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: 100%;
|
||||
max-width: 300px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
@@ -12,12 +12,10 @@ function HomepageHeader() {
|
||||
return (
|
||||
<header className={clsx("hero hero--primary", styles.heroBanner)}>
|
||||
<div className="container">
|
||||
<img className={styles.logo} src="img/logo-lg.svg" alt="Simple Scaffold" />
|
||||
<Heading as="h1" className="hero__title">
|
||||
{siteConfig.title}
|
||||
</Heading>
|
||||
<p className="hero__subtitle">{siteConfig.tagline}</p>
|
||||
<img className={styles.heroImage} src="img/intro.gif" alt="Simple-Scaffold doing its thing" />
|
||||
<div className={styles.buttons}>
|
||||
<Link className="button button--secondary button--lg" to="/docs/api">
|
||||
API
|
||||
|
||||
BIN
docs/static/img/favicon.png
vendored
|
Before Width: | Height: | Size: 14 KiB |
20
docs/static/img/favicon.svg
vendored
|
Before Width: | Height: | Size: 265 KiB |
BIN
docs/static/img/intro.gif
vendored
|
Before Width: | Height: | Size: 385 KiB |
BIN
docs/static/img/logo-lg.png
vendored
|
Before Width: | Height: | Size: 22 KiB |
20
docs/static/img/logo-lg.svg
vendored
|
Before Width: | Height: | Size: 281 KiB |
BIN
docs/static/img/logo.png
vendored
|
Before Width: | Height: | Size: 24 KiB |
21
docs/static/img/logo.svg
vendored
|
Before Width: | Height: | Size: 432 KiB After Width: | Height: | Size: 6.3 KiB |
21
package.json
@@ -1,19 +1,14 @@
|
||||
{
|
||||
"name": "simple-scaffold",
|
||||
"version": "2.0.2-pre.1",
|
||||
"version": "0.0.0",
|
||||
"description": "Generate any file structure - from single components to entire app boilerplates, with a single command.",
|
||||
"homepage": "https: //chenasraf.github.io/simple-scaffold",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/chenasraf/simple-scaffold.git"
|
||||
},
|
||||
"author": "Chen Asraf <contact@casraf.dev> (https://casraf.dev)",
|
||||
"homepage": "https://chenasraf.github.io/simple-scaffold",
|
||||
"repository": "https://github.com/chenasraf/simple-scaffold.git",
|
||||
"author": "Chen Asraf <contact@casraf.dev>",
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
"simple-scaffold": "cmd.js"
|
||||
},
|
||||
"packageManager": "pnpm@8.15.1",
|
||||
"bin": "cmd.js",
|
||||
"packageManager": "pnpm@8.6.2",
|
||||
"keywords": [
|
||||
"javascript",
|
||||
"cli",
|
||||
@@ -42,7 +37,7 @@
|
||||
"date-fns": "^3.3.1",
|
||||
"glob": "^10.3.10",
|
||||
"handlebars": "^4.7.8",
|
||||
"massarg": "2.0.0"
|
||||
"massarg": "2.0.0-pre.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@semantic-release/changelog": "^6.0.3",
|
||||
@@ -51,7 +46,7 @@
|
||||
"@semantic-release/release-notes-generator": "^12.1.0",
|
||||
"@types/jest": "^29.5.11",
|
||||
"@types/mock-fs": "^4.13.4",
|
||||
"@types/node": "^20.11.14",
|
||||
"@types/node": "^20.11.10",
|
||||
"@types/semantic-release": "^20.0.6",
|
||||
"conventional-changelog": "^5.1.0",
|
||||
"conventional-changelog-cli": "^4.1.0",
|
||||
|
||||
104
pnpm-lock.yaml
generated
@@ -18,8 +18,8 @@ dependencies:
|
||||
specifier: ^4.7.8
|
||||
version: 4.7.8
|
||||
massarg:
|
||||
specifier: 2.0.0
|
||||
version: 2.0.0
|
||||
specifier: 2.0.0-pre.12
|
||||
version: 2.0.0-pre.12
|
||||
|
||||
devDependencies:
|
||||
'@semantic-release/changelog':
|
||||
@@ -41,8 +41,8 @@ devDependencies:
|
||||
specifier: ^4.13.4
|
||||
version: 4.13.4
|
||||
'@types/node':
|
||||
specifier: ^20.11.14
|
||||
version: 20.11.14
|
||||
specifier: ^20.11.10
|
||||
version: 20.11.10
|
||||
'@types/semantic-release':
|
||||
specifier: ^20.0.6
|
||||
version: 20.0.6
|
||||
@@ -54,7 +54,7 @@ devDependencies:
|
||||
version: 4.1.0
|
||||
jest:
|
||||
specifier: ^29.7.0
|
||||
version: 29.7.0(@types/node@20.11.14)(ts-node@10.9.2)
|
||||
version: 29.7.0(@types/node@20.11.10)(ts-node@10.9.2)
|
||||
mock-fs:
|
||||
specifier: ^5.2.0
|
||||
version: 5.2.0
|
||||
@@ -69,7 +69,7 @@ devDependencies:
|
||||
version: 29.1.2(@babel/core@7.23.9)(jest@29.7.0)(typescript@5.3.3)
|
||||
ts-node:
|
||||
specifier: ^10.9.2
|
||||
version: 10.9.2(@types/node@20.11.14)(typescript@5.3.3)
|
||||
version: 10.9.2(@types/node@20.11.10)(typescript@5.3.3)
|
||||
typescript:
|
||||
specifier: ^5.3.3
|
||||
version: 5.3.3
|
||||
@@ -465,7 +465,7 @@ packages:
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
dependencies:
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
chalk: 4.1.2
|
||||
jest-message-util: 29.7.0
|
||||
jest-util: 29.7.0
|
||||
@@ -486,14 +486,14 @@ packages:
|
||||
'@jest/test-result': 29.7.0
|
||||
'@jest/transform': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
ansi-escapes: 4.3.2
|
||||
chalk: 4.1.2
|
||||
ci-info: 3.9.0
|
||||
exit: 0.1.2
|
||||
graceful-fs: 4.2.11
|
||||
jest-changed-files: 29.7.0
|
||||
jest-config: 29.7.0(@types/node@20.11.14)(ts-node@10.9.2)
|
||||
jest-config: 29.7.0(@types/node@20.11.10)(ts-node@10.9.2)
|
||||
jest-haste-map: 29.7.0
|
||||
jest-message-util: 29.7.0
|
||||
jest-regex-util: 29.6.3
|
||||
@@ -521,7 +521,7 @@ packages:
|
||||
dependencies:
|
||||
'@jest/fake-timers': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
jest-mock: 29.7.0
|
||||
dev: true
|
||||
|
||||
@@ -548,7 +548,7 @@ packages:
|
||||
dependencies:
|
||||
'@jest/types': 29.6.3
|
||||
'@sinonjs/fake-timers': 10.3.0
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
jest-message-util: 29.7.0
|
||||
jest-mock: 29.7.0
|
||||
jest-util: 29.7.0
|
||||
@@ -581,7 +581,7 @@ packages:
|
||||
'@jest/transform': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@jridgewell/trace-mapping': 0.3.22
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
chalk: 4.1.2
|
||||
collect-v8-coverage: 1.0.2
|
||||
exit: 0.1.2
|
||||
@@ -669,7 +669,7 @@ packages:
|
||||
'@jest/schemas': 29.6.3
|
||||
'@types/istanbul-lib-coverage': 2.0.6
|
||||
'@types/istanbul-reports': 3.0.4
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
'@types/yargs': 17.0.32
|
||||
chalk: 4.1.2
|
||||
dev: true
|
||||
@@ -1078,7 +1078,7 @@ packages:
|
||||
/@types/graceful-fs@4.1.9:
|
||||
resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==}
|
||||
dependencies:
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
dev: true
|
||||
|
||||
/@types/istanbul-lib-coverage@2.0.6:
|
||||
@@ -1111,11 +1111,11 @@ packages:
|
||||
/@types/mock-fs@4.13.4:
|
||||
resolution: {integrity: sha512-mXmM0o6lULPI8z3XNnQCpL0BGxPwx1Ul1wXYEPBGl4efShyxW2Rln0JOPEWGyZaYZMM6OVXM/15zUuFMY52ljg==}
|
||||
dependencies:
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
dev: true
|
||||
|
||||
/@types/node@20.11.14:
|
||||
resolution: {integrity: sha512-w3yWCcwULefjP9DmDDsgUskrMoOy5Z8MiwKHr1FvqGPtx7CvJzQvxD7eKpxNtklQxLruxSXWddyeRtyud0RcXQ==}
|
||||
/@types/node@20.11.10:
|
||||
resolution: {integrity: sha512-rZEfe/hJSGYmdfX9tvcPMYeYPW2sNl50nsw4jZmRcaG0HIAb0WYEpsB05GOb53vjqpyE9GUhlDQ4jLSoB5q9kg==}
|
||||
dependencies:
|
||||
undici-types: 5.26.5
|
||||
dev: true
|
||||
@@ -1127,7 +1127,7 @@ packages:
|
||||
/@types/semantic-release@20.0.6:
|
||||
resolution: {integrity: sha512-8YJXvsT1FwMrNdZI1e6NBHPzZWendDiUsLryzxurdup+9LnV3s9fF4NgO0D3LkBfLMnocb4Ax6TQ5yFdF3dXGQ==}
|
||||
dependencies:
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
dev: true
|
||||
|
||||
/@types/stack-utils@2.0.3:
|
||||
@@ -1386,7 +1386,7 @@ packages:
|
||||
hasBin: true
|
||||
dependencies:
|
||||
caniuse-lite: 1.0.30001581
|
||||
electron-to-chromium: 1.4.652
|
||||
electron-to-chromium: 1.4.648
|
||||
node-releases: 2.0.14
|
||||
update-browserslist-db: 1.0.13(browserslist@4.22.3)
|
||||
dev: true
|
||||
@@ -1721,7 +1721,7 @@ packages:
|
||||
typescript: 5.3.3
|
||||
dev: true
|
||||
|
||||
/create-jest@29.7.0(@types/node@20.11.14)(ts-node@10.9.2):
|
||||
/create-jest@29.7.0(@types/node@20.11.10)(ts-node@10.9.2):
|
||||
resolution: {integrity: sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
hasBin: true
|
||||
@@ -1730,7 +1730,7 @@ packages:
|
||||
chalk: 4.1.2
|
||||
exit: 0.1.2
|
||||
graceful-fs: 4.2.11
|
||||
jest-config: 29.7.0(@types/node@20.11.14)(ts-node@10.9.2)
|
||||
jest-config: 29.7.0(@types/node@20.11.10)(ts-node@10.9.2)
|
||||
jest-util: 29.7.0
|
||||
prompts: 2.4.2
|
||||
transitivePeerDependencies:
|
||||
@@ -1855,8 +1855,8 @@ packages:
|
||||
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
|
||||
dev: false
|
||||
|
||||
/electron-to-chromium@1.4.652:
|
||||
resolution: {integrity: sha512-XvQaa8hVUAuEJtLw6VKQqvdOxTOfBLWfI10t2xWpezx4XXD3k8bdLweEKeItqaa0+OkJX5l0mP1W+JWobyIDrg==}
|
||||
/electron-to-chromium@1.4.648:
|
||||
resolution: {integrity: sha512-EmFMarXeqJp9cUKu/QEciEApn0S/xRcpZWuAm32U7NgoZCimjsilKXHRO9saeEW55eHZagIDg6XTUOv32w9pjg==}
|
||||
dev: true
|
||||
|
||||
/emittery@0.13.1:
|
||||
@@ -2556,7 +2556,7 @@ packages:
|
||||
'@jest/expect': 29.7.0
|
||||
'@jest/test-result': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
chalk: 4.1.2
|
||||
co: 4.6.0
|
||||
dedent: 1.5.1
|
||||
@@ -2577,7 +2577,7 @@ packages:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/jest-cli@29.7.0(@types/node@20.11.14)(ts-node@10.9.2):
|
||||
/jest-cli@29.7.0(@types/node@20.11.10)(ts-node@10.9.2):
|
||||
resolution: {integrity: sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
hasBin: true
|
||||
@@ -2591,10 +2591,10 @@ packages:
|
||||
'@jest/test-result': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
chalk: 4.1.2
|
||||
create-jest: 29.7.0(@types/node@20.11.14)(ts-node@10.9.2)
|
||||
create-jest: 29.7.0(@types/node@20.11.10)(ts-node@10.9.2)
|
||||
exit: 0.1.2
|
||||
import-local: 3.1.0
|
||||
jest-config: 29.7.0(@types/node@20.11.14)(ts-node@10.9.2)
|
||||
jest-config: 29.7.0(@types/node@20.11.10)(ts-node@10.9.2)
|
||||
jest-util: 29.7.0
|
||||
jest-validate: 29.7.0
|
||||
yargs: 17.7.2
|
||||
@@ -2605,7 +2605,7 @@ packages:
|
||||
- ts-node
|
||||
dev: true
|
||||
|
||||
/jest-config@29.7.0(@types/node@20.11.14)(ts-node@10.9.2):
|
||||
/jest-config@29.7.0(@types/node@20.11.10)(ts-node@10.9.2):
|
||||
resolution: {integrity: sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
peerDependencies:
|
||||
@@ -2620,7 +2620,7 @@ packages:
|
||||
'@babel/core': 7.23.9
|
||||
'@jest/test-sequencer': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
babel-jest: 29.7.0(@babel/core@7.23.9)
|
||||
chalk: 4.1.2
|
||||
ci-info: 3.9.0
|
||||
@@ -2640,7 +2640,7 @@ packages:
|
||||
pretty-format: 29.7.0
|
||||
slash: 3.0.0
|
||||
strip-json-comments: 3.1.1
|
||||
ts-node: 10.9.2(@types/node@20.11.14)(typescript@5.3.3)
|
||||
ts-node: 10.9.2(@types/node@20.11.10)(typescript@5.3.3)
|
||||
transitivePeerDependencies:
|
||||
- babel-plugin-macros
|
||||
- supports-color
|
||||
@@ -2681,7 +2681,7 @@ packages:
|
||||
'@jest/environment': 29.7.0
|
||||
'@jest/fake-timers': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
jest-mock: 29.7.0
|
||||
jest-util: 29.7.0
|
||||
dev: true
|
||||
@@ -2697,7 +2697,7 @@ packages:
|
||||
dependencies:
|
||||
'@jest/types': 29.6.3
|
||||
'@types/graceful-fs': 4.1.9
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
anymatch: 3.1.3
|
||||
fb-watchman: 2.0.2
|
||||
graceful-fs: 4.2.11
|
||||
@@ -2748,7 +2748,7 @@ packages:
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
dependencies:
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
jest-util: 29.7.0
|
||||
dev: true
|
||||
|
||||
@@ -2803,7 +2803,7 @@ packages:
|
||||
'@jest/test-result': 29.7.0
|
||||
'@jest/transform': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
chalk: 4.1.2
|
||||
emittery: 0.13.1
|
||||
graceful-fs: 4.2.11
|
||||
@@ -2834,7 +2834,7 @@ packages:
|
||||
'@jest/test-result': 29.7.0
|
||||
'@jest/transform': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
chalk: 4.1.2
|
||||
cjs-module-lexer: 1.2.3
|
||||
collect-v8-coverage: 1.0.2
|
||||
@@ -2886,7 +2886,7 @@ packages:
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
dependencies:
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
chalk: 4.1.2
|
||||
ci-info: 3.9.0
|
||||
graceful-fs: 4.2.11
|
||||
@@ -2911,7 +2911,7 @@ packages:
|
||||
dependencies:
|
||||
'@jest/test-result': 29.7.0
|
||||
'@jest/types': 29.6.3
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
ansi-escapes: 4.3.2
|
||||
chalk: 4.1.2
|
||||
emittery: 0.13.1
|
||||
@@ -2923,13 +2923,13 @@ packages:
|
||||
resolution: {integrity: sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
dependencies:
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
jest-util: 29.7.0
|
||||
merge-stream: 2.0.0
|
||||
supports-color: 8.1.1
|
||||
dev: true
|
||||
|
||||
/jest@29.7.0(@types/node@20.11.14)(ts-node@10.9.2):
|
||||
/jest@29.7.0(@types/node@20.11.10)(ts-node@10.9.2):
|
||||
resolution: {integrity: sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==}
|
||||
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
|
||||
hasBin: true
|
||||
@@ -2942,7 +2942,7 @@ packages:
|
||||
'@jest/core': 29.7.0(ts-node@10.9.2)
|
||||
'@jest/types': 29.6.3
|
||||
import-local: 3.1.0
|
||||
jest-cli: 29.7.0(@types/node@20.11.14)(ts-node@10.9.2)
|
||||
jest-cli: 29.7.0(@types/node@20.11.10)(ts-node@10.9.2)
|
||||
transitivePeerDependencies:
|
||||
- '@types/node'
|
||||
- babel-plugin-macros
|
||||
@@ -3164,8 +3164,8 @@ packages:
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/massarg@2.0.0:
|
||||
resolution: {integrity: sha512-oeB1dT/e4K3GBCPmUPwPXybeZbjrAnjsoMWSqshlfs4ndkeNdyxEHr6UAf0bkZMu3pqxT/QqembAM4nrUcPrAQ==}
|
||||
/massarg@2.0.0-pre.12:
|
||||
resolution: {integrity: sha512-ncD9mXRQh4y8IIi5qcNEzh0qsqXyVq0FH0/v2vdMy/+WJCdAIuKG3TqlWML1SWMH4QdqZ/XJnbDfp8u2i91NNg==}
|
||||
dependencies:
|
||||
zod: 3.22.4
|
||||
dev: false
|
||||
@@ -3581,7 +3581,7 @@ packages:
|
||||
dependencies:
|
||||
'@babel/code-frame': 7.23.5
|
||||
index-to-position: 0.1.2
|
||||
type-fest: 4.10.2
|
||||
type-fest: 4.10.1
|
||||
dev: true
|
||||
|
||||
/path-exists@3.0.0:
|
||||
@@ -3727,7 +3727,7 @@ packages:
|
||||
dependencies:
|
||||
find-up: 6.3.0
|
||||
read-pkg: 8.1.0
|
||||
type-fest: 4.10.2
|
||||
type-fest: 4.10.1
|
||||
dev: true
|
||||
|
||||
/read-pkg-up@11.0.0:
|
||||
@@ -3737,7 +3737,7 @@ packages:
|
||||
dependencies:
|
||||
find-up-simple: 1.0.0
|
||||
read-pkg: 9.0.1
|
||||
type-fest: 4.10.2
|
||||
type-fest: 4.10.1
|
||||
dev: true
|
||||
|
||||
/read-pkg-up@7.0.1:
|
||||
@@ -3766,7 +3766,7 @@ packages:
|
||||
'@types/normalize-package-data': 2.4.4
|
||||
normalize-package-data: 6.0.0
|
||||
parse-json: 7.1.1
|
||||
type-fest: 4.10.2
|
||||
type-fest: 4.10.1
|
||||
dev: true
|
||||
|
||||
/read-pkg@9.0.1:
|
||||
@@ -3776,7 +3776,7 @@ packages:
|
||||
'@types/normalize-package-data': 2.4.4
|
||||
normalize-package-data: 6.0.0
|
||||
parse-json: 8.1.0
|
||||
type-fest: 4.10.2
|
||||
type-fest: 4.10.1
|
||||
unicorn-magic: 0.1.0
|
||||
dev: true
|
||||
|
||||
@@ -4301,7 +4301,7 @@ packages:
|
||||
'@babel/core': 7.23.9
|
||||
bs-logger: 0.2.6
|
||||
fast-json-stable-stringify: 2.1.0
|
||||
jest: 29.7.0(@types/node@20.11.14)(ts-node@10.9.2)
|
||||
jest: 29.7.0(@types/node@20.11.10)(ts-node@10.9.2)
|
||||
jest-util: 29.7.0
|
||||
json5: 2.2.3
|
||||
lodash.memoize: 4.1.2
|
||||
@@ -4311,7 +4311,7 @@ packages:
|
||||
yargs-parser: 21.1.1
|
||||
dev: true
|
||||
|
||||
/ts-node@10.9.2(@types/node@20.11.14)(typescript@5.3.3):
|
||||
/ts-node@10.9.2(@types/node@20.11.10)(typescript@5.3.3):
|
||||
resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
@@ -4330,7 +4330,7 @@ packages:
|
||||
'@tsconfig/node12': 1.0.11
|
||||
'@tsconfig/node14': 1.0.3
|
||||
'@tsconfig/node16': 1.0.4
|
||||
'@types/node': 20.11.14
|
||||
'@types/node': 20.11.10
|
||||
acorn: 8.11.3
|
||||
acorn-walk: 8.3.2
|
||||
arg: 4.1.3
|
||||
@@ -4382,8 +4382,8 @@ packages:
|
||||
engines: {node: '>=14.16'}
|
||||
dev: true
|
||||
|
||||
/type-fest@4.10.2:
|
||||
resolution: {integrity: sha512-anpAG63wSpdEbLwOqH8L84urkL6PiVIov3EMmgIhhThevh9aiMQov+6Btx0wldNcvm4wV+e2/Rt1QdDwKHFbHw==}
|
||||
/type-fest@4.10.1:
|
||||
resolution: {integrity: sha512-7ZnJYTp6uc04uYRISWtiX3DSKB/fxNQT0B5o1OUeCqiQiwF+JC9+rJiZIDrPrNCLLuTqyQmh4VdQqh/ZOkv9MQ==}
|
||||
engines: {node: '>=16'}
|
||||
dev: true
|
||||
|
||||
|
||||
@@ -1,69 +1,37 @@
|
||||
const ref = process.env.GITHUB_REF || ""
|
||||
const branch = ref.split("/").pop()
|
||||
|
||||
/**
|
||||
* @type {import('semantic-release').GlobalConfig}
|
||||
*/
|
||||
/** @type {import('semantic-release').Options} */
|
||||
module.exports = {
|
||||
branches: ["master", { name: "pre", prerelease: true }],
|
||||
analyzeCommits: {
|
||||
path: "semantic-release-conventional-commits",
|
||||
},
|
||||
plugins: [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"@semantic-release/release-notes-generator",
|
||||
[
|
||||
"@semantic-release/npm",
|
||||
"@semantic-release/changelog",
|
||||
{
|
||||
// only update the pkg version on root, don't publish
|
||||
npmPublish: false,
|
||||
},
|
||||
],
|
||||
// [
|
||||
// '@semantic-release/npm',
|
||||
// {
|
||||
// // only update the pkg version on doc, don't publish
|
||||
// npmPublish: false,
|
||||
// pkgRoot: 'doc',
|
||||
// },
|
||||
// ]
|
||||
[
|
||||
"@semantic-release/exec",
|
||||
{
|
||||
publish: "cd ./dist && pnpm pack --pack-destination=../",
|
||||
changelogFile: "CHANGELOG.md",
|
||||
changelogTitle: "# Change Log",
|
||||
},
|
||||
],
|
||||
[
|
||||
"@semantic-release/npm",
|
||||
{
|
||||
// publish from dist dir instead of root
|
||||
npmPublish: true,
|
||||
pkgRoot: "dist",
|
||||
},
|
||||
],
|
||||
[
|
||||
"@semantic-release/git",
|
||||
{
|
||||
assets: ["CHANGELOG.md"],
|
||||
},
|
||||
],
|
||||
[
|
||||
"@semantic-release/github",
|
||||
{
|
||||
assets: ["*.tgz"],
|
||||
},
|
||||
],
|
||||
branch === "master"
|
||||
? [
|
||||
"@semantic-release/changelog",
|
||||
{
|
||||
changelogFile: "CHANGELOG.md",
|
||||
changelogTitle: "# Change Log",
|
||||
},
|
||||
]
|
||||
: undefined,
|
||||
[
|
||||
"@semantic-release/git",
|
||||
{
|
||||
assets: ["package.json", "CHANGELOG.md"].filter(Boolean),
|
||||
},
|
||||
],
|
||||
//
|
||||
// [
|
||||
// '@semantic-release/exec',
|
||||
// {
|
||||
// verifyReleaseCmd: 'echo ${nextRelease.version} > .VERSION',
|
||||
// },
|
||||
// ],
|
||||
].filter(Boolean),
|
||||
],
|
||||
}
|
||||
|
||||
37
src/cmd.ts
@@ -1,6 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import os from "node:os"
|
||||
import { massarg } from "massarg"
|
||||
import chalk from "chalk"
|
||||
import { LogLevel, ScaffoldCmdConfig } from "./types"
|
||||
@@ -8,35 +6,21 @@ import { Scaffold } from "./scaffold"
|
||||
import path from "node:path"
|
||||
import fs from "node:fs/promises"
|
||||
import { parseAppendData, parseConfigFile } from "./config"
|
||||
import { log } from "./logger"
|
||||
|
||||
export async function parseCliArgs(args = process.argv.slice(2)) {
|
||||
const isProjectRoot = Boolean(await fs.stat(path.join(__dirname, "package.json")).catch(() => false))
|
||||
const pkgFile = await fs.readFile(path.resolve(__dirname, isProjectRoot ? "." : "..", "package.json"))
|
||||
const pkg = JSON.parse(pkgFile.toString())
|
||||
const isVersionFlag = args.includes("--version") || args.includes("-v")
|
||||
const isConfigProvided =
|
||||
args.includes("--config") || args.includes("-c") || args.includes("--git") || args.includes("-g") || isVersionFlag
|
||||
args.includes("--config") || args.includes("-c") || args.includes("--git") || args.includes("-g")
|
||||
|
||||
return massarg<ScaffoldCmdConfig>({
|
||||
name: pkg.name,
|
||||
description: pkg.description,
|
||||
})
|
||||
.main(async (config) => {
|
||||
if (config.version) {
|
||||
console.log(pkg.version)
|
||||
return
|
||||
}
|
||||
log(config, LogLevel.info, `Simple Scaffold v${pkg.version}`)
|
||||
const tmpPath = path.resolve(os.tmpdir(), `scaffold-config-${Date.now()}`)
|
||||
try {
|
||||
log(config, LogLevel.debug, "Parsing config file...", config)
|
||||
const parsed = await parseConfigFile(config, tmpPath)
|
||||
await Scaffold(parsed)
|
||||
} finally {
|
||||
log(config, LogLevel.debug, "Cleaning up temporary files...", tmpPath)
|
||||
await fs.rm(tmpPath, { recursive: true, force: true })
|
||||
}
|
||||
const parsed = await parseConfigFile(config)
|
||||
return Scaffold(parsed)
|
||||
})
|
||||
.option({
|
||||
name: "name",
|
||||
@@ -45,7 +29,7 @@ export async function parseCliArgs(args = process.argv.slice(2)) {
|
||||
"Name to be passed to the generated files. `{{name}}` and other data parameters inside " +
|
||||
"contents and file names will be replaced accordingly. You may omit the `--name` or `-n` for this specific option.",
|
||||
isDefault: true,
|
||||
required: !isVersionFlag,
|
||||
required: true,
|
||||
})
|
||||
.option({
|
||||
name: "config",
|
||||
@@ -135,13 +119,7 @@ export async function parseCliArgs(args = process.argv.slice(2)) {
|
||||
"Determine amount of logs to display. The values are: " +
|
||||
`${chalk.bold`\`none | debug | info | warn | error\``}. ` +
|
||||
"The provided level will display messages of the same level or higher.",
|
||||
parse: (v) => {
|
||||
const val = v.toLowerCase()
|
||||
if (!(val in LogLevel)) {
|
||||
throw new Error(`Invalid log level: ${val}, must be one of: ${Object.keys(LogLevel).join(", ")}`)
|
||||
}
|
||||
return val
|
||||
},
|
||||
parse: Number,
|
||||
})
|
||||
.flag({
|
||||
name: "dry-run",
|
||||
@@ -151,11 +129,6 @@ export async function parseCliArgs(args = process.argv.slice(2)) {
|
||||
"Don't emit files. This is good for testing your scaffolds and making sure they " +
|
||||
"don't fail, without having to write actual file contents or create directories.",
|
||||
})
|
||||
.flag({
|
||||
name: "version",
|
||||
aliases: ["v"],
|
||||
description: "Display version.",
|
||||
})
|
||||
.example({
|
||||
description: "Usage with config file",
|
||||
input: "simple-scaffold -c scaffold.cmd.js --key component",
|
||||
|
||||
@@ -48,7 +48,7 @@ function isWrappedWithQuotes(string: string): boolean {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export async function parseConfigFile(config: ScaffoldCmdConfig, tmpPath: string): Promise<ScaffoldConfig> {
|
||||
export async function parseConfigFile(config: ScaffoldCmdConfig): Promise<ScaffoldConfig> {
|
||||
let output: ScaffoldConfig = config
|
||||
|
||||
if (config.quiet) {
|
||||
@@ -69,9 +69,8 @@ export async function parseConfigFile(config: ScaffoldCmdConfig, tmpPath: string
|
||||
const configPath = isGit ? config.git : configFilename
|
||||
|
||||
log(config, LogLevel.info, `Loading config from ${configFilename} with key ${key}`)
|
||||
|
||||
const configPromise = await (isGit
|
||||
? getRemoteConfig({ git: configPath, config: configFilename, logLevel: config.logLevel, tmpPath })
|
||||
const configPromise = await (config.git
|
||||
? getRemoteConfig({ git: configPath, config: configFilename, logLevel: config.logLevel })
|
||||
: getLocalConfig({ config: configFilename, logLevel: config.logLevel }))
|
||||
|
||||
// resolve the config
|
||||
@@ -124,7 +123,7 @@ export async function getLocalConfig(config: ConfigLoadConfig & Partial<LogConfi
|
||||
export async function getRemoteConfig(
|
||||
config: RemoteConfigLoadConfig & Partial<LogConfig>,
|
||||
): Promise<ScaffoldConfigFile> {
|
||||
const { config: configFile, git, tmpPath, ...logConfig } = config as Required<typeof config>
|
||||
const { config: configFile, git, ...logConfig } = config as Required<typeof config>
|
||||
|
||||
log(logConfig, LogLevel.info, `Loading config from remote ${git}, file ${configFile}`)
|
||||
|
||||
@@ -136,5 +135,5 @@ export async function getRemoteConfig(
|
||||
throw new Error(`Unsupported protocol ${url.protocol}`)
|
||||
}
|
||||
|
||||
return getGitConfig(url, configFile, tmpPath, logConfig)
|
||||
return getGitConfig(url, configFile, logConfig)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import path from "node:path"
|
||||
import os from "node:os"
|
||||
import fs from "node:fs/promises"
|
||||
import { log } from "./logger"
|
||||
import { AsyncResolver, LogConfig, LogLevel, ScaffoldCmdConfig, ScaffoldConfigMap } from "./types"
|
||||
@@ -8,15 +9,15 @@ import { resolve, wrapNoopResolver } from "./utils"
|
||||
export async function getGitConfig(
|
||||
url: URL,
|
||||
file: string,
|
||||
tmpPath: string,
|
||||
logConfig: LogConfig,
|
||||
): Promise<AsyncResolver<ScaffoldCmdConfig, ScaffoldConfigMap>> {
|
||||
const repoUrl = `${url.protocol}//${url.host}${url.pathname}`
|
||||
|
||||
log(logConfig, LogLevel.info, `Cloning git repo ${repoUrl}`)
|
||||
|
||||
const tmpPath = path.resolve(os.tmpdir(), `scaffold-config-${Date.now()}`)
|
||||
|
||||
return new Promise((res, reject) => {
|
||||
log(logConfig, LogLevel.debug, `Cloning git repo to ${tmpPath}`)
|
||||
const clone = spawn("git", ["clone", "--recurse-submodules", "--depth", "1", repoUrl, tmpPath])
|
||||
|
||||
clone.on("error", reject)
|
||||
@@ -46,7 +47,6 @@ export async function loadGitConfig({
|
||||
log(logConfig, LogLevel.info, `Loading config from git repo: ${repoUrl}`)
|
||||
const filename = file || (await findConfigFile(tmpPath))
|
||||
const absolutePath = path.resolve(tmpPath, filename)
|
||||
log(logConfig, LogLevel.debug, `Resolving config file: ${absolutePath}`)
|
||||
const loadedConfig = await resolve(async () => (await import(absolutePath)).default as ScaffoldConfigMap, logConfig)
|
||||
|
||||
log(logConfig, LogLevel.info, `Loaded config from git`)
|
||||
@@ -58,6 +58,7 @@ export async function loadGitConfig({
|
||||
templates: v.templates.map((t) => path.resolve(tmpPath, t)),
|
||||
}
|
||||
}
|
||||
await fs.rm(tmpPath, { recursive: true })
|
||||
return wrapNoopResolver(fixedConfig)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
export * from "./scaffold"
|
||||
export * from "./types"
|
||||
import Scaffold from "./scaffold"
|
||||
|
||||
export default Scaffold
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
* See [readme](README.md)
|
||||
*/
|
||||
import path from "node:path"
|
||||
import os from "node:os"
|
||||
|
||||
import { handleErr, resolve } from "./utils"
|
||||
import {
|
||||
isDir,
|
||||
@@ -128,12 +126,10 @@ Scaffold.fromConfig = async function (
|
||||
subdir: false,
|
||||
quiet: false,
|
||||
config: pathOrUrl,
|
||||
version: false,
|
||||
...config,
|
||||
}
|
||||
const tmpPath = path.resolve(os.tmpdir(), `scaffold-config-${Date.now()}`)
|
||||
const _overrides = resolve(overrides, _cmdConfig)
|
||||
const _config = await parseConfigFile(_cmdConfig, tmpPath)
|
||||
const _config = await parseConfigFile(_cmdConfig)
|
||||
return Scaffold({ ..._config, ..._overrides })
|
||||
}
|
||||
|
||||
|
||||
38
src/types.ts
@@ -257,18 +257,6 @@ export type DefaultHelpers = CaseHelpers | DateHelpers
|
||||
*/
|
||||
export type Helper = HelperDelegate
|
||||
|
||||
/**
|
||||
* The amount of information to log when generating scaffold.
|
||||
* When not `none`, the selected level will be the lowest level included.
|
||||
*
|
||||
* For example, level `info` will include `info`, `warning` and `error`, but not `debug`; and `warning` will only
|
||||
* show `warning` and `error`, but not `info` or `debug`.
|
||||
*
|
||||
* @default `info`
|
||||
*
|
||||
* @category Logging (const)
|
||||
*/
|
||||
|
||||
export const LogLevel = {
|
||||
/** Silent output */
|
||||
none: "none",
|
||||
@@ -288,14 +276,17 @@ export const LogLevel = {
|
||||
|
||||
/**
|
||||
* The amount of information to log when generating scaffold.
|
||||
* When not `none`, the selected level will be the lowest level included.
|
||||
* When not `None`, the selected level will be the lowest level included.
|
||||
*
|
||||
* For example, level `info` will include `info`, `warning` and `error`, but not `debug`; and `warning` will only
|
||||
* show `warning` and `error`, but not `info` or `debug`.
|
||||
* For example, level `Info` (2) will include `Info`, `Warning` and `Error`, but not `Debug`; and `Warning` will only
|
||||
* show `Warning` and `Error`.
|
||||
*
|
||||
* @default `info`
|
||||
* You may use either the number or the name of the level.
|
||||
* For example, `2` or `info` are both valid.
|
||||
*
|
||||
* @category Logging (type)
|
||||
* @default `2 (info)`
|
||||
*
|
||||
* @category Logging
|
||||
*/
|
||||
export type LogLevel = (typeof LogLevel)[keyof typeof LogLevel]
|
||||
|
||||
@@ -333,7 +324,7 @@ export type FileResponse<T> = T | FileResponseHandler<T>
|
||||
* The Scaffold config for CLI
|
||||
* Contains less and more specific options than {@link ScaffoldConfig}
|
||||
*/
|
||||
export type ScaffoldCmdConfig = {
|
||||
export interface ScaffoldCmdConfig {
|
||||
/** The name of the scaffold template to use. */
|
||||
name: string
|
||||
/** The templates to use for generation */
|
||||
@@ -366,8 +357,6 @@ export type ScaffoldCmdConfig = {
|
||||
key?: string
|
||||
/** The git repository to use to fetch the config file */
|
||||
git?: string
|
||||
/** Display version */
|
||||
version: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -380,19 +369,14 @@ export type ScaffoldCmdConfig = {
|
||||
* When no template key is provided to the scaffold command, the "default" template is used.
|
||||
*
|
||||
* @see {@link ScaffoldConfig}
|
||||
*
|
||||
* @category Config
|
||||
*/
|
||||
export type ScaffoldConfigMap = Record<string, ScaffoldConfig>
|
||||
|
||||
/**
|
||||
* The scaffold config file is either:
|
||||
/** The scaffold config file is either:
|
||||
* - A {@link ScaffoldConfigMap} object
|
||||
* - A function that returns a {@link ScaffoldConfigMap} object
|
||||
* - A promise that resolves to a {@link ScaffoldConfigMap} object
|
||||
* - A function that returns a promise that resolves to a {@link ScaffoldConfigMap} object
|
||||
*
|
||||
* @category Config
|
||||
*/
|
||||
export type ScaffoldConfigFile = AsyncResolver<ScaffoldCmdConfig, ScaffoldConfigMap>
|
||||
|
||||
@@ -409,7 +393,7 @@ export type LogConfig = Pick<ScaffoldConfig, "logLevel">
|
||||
export type ConfigLoadConfig = LogConfig & Pick<ScaffoldCmdConfig, "config">
|
||||
|
||||
/** @internal */
|
||||
export type RemoteConfigLoadConfig = LogConfig & Pick<ScaffoldCmdConfig, "config" | "git"> & { tmpPath: string }
|
||||
export type RemoteConfigLoadConfig = LogConfig & Pick<ScaffoldCmdConfig, "config" | "git">
|
||||
|
||||
/** @internal */
|
||||
export type MinimalConfig = Pick<ScaffoldCmdConfig, "name" | "key">
|
||||
|
||||
@@ -30,7 +30,6 @@ const blankCliConf: ScaffoldCmdConfig = {
|
||||
subdir: false,
|
||||
dryRun: false,
|
||||
quiet: false,
|
||||
version: false,
|
||||
}
|
||||
|
||||
const blankConfig: ScaffoldCmdConfig = {
|
||||
@@ -69,34 +68,25 @@ describe("config", () => {
|
||||
describe("parseConfigFile", () => {
|
||||
test("normal config does not change", async () => {
|
||||
expect(
|
||||
await parseConfigFile(
|
||||
{
|
||||
...blankCliConf,
|
||||
},
|
||||
`/tmp/scaffold-config-${Date.now()}`,
|
||||
),
|
||||
await parseConfigFile({
|
||||
...blankCliConf,
|
||||
}),
|
||||
).toEqual(blankCliConf)
|
||||
})
|
||||
describe("appendData", () => {
|
||||
test("appends", async () => {
|
||||
const result = await parseConfigFile(
|
||||
{
|
||||
...blankCliConf,
|
||||
appendData: { key: "value" },
|
||||
},
|
||||
`/tmp/scaffold-config-${Date.now()}`,
|
||||
)
|
||||
const result = await parseConfigFile({
|
||||
...blankCliConf,
|
||||
appendData: { key: "value" },
|
||||
})
|
||||
expect(result?.data?.key).toEqual("value")
|
||||
})
|
||||
test("overwrites existing value", async () => {
|
||||
const result = await parseConfigFile(
|
||||
{
|
||||
...blankCliConf,
|
||||
data: { num: "123" },
|
||||
appendData: { num: "1234" },
|
||||
},
|
||||
`/tmp/scaffold-config-${Date.now()}`,
|
||||
)
|
||||
const result = await parseConfigFile({
|
||||
...blankCliConf,
|
||||
data: { num: "123" },
|
||||
appendData: { num: "1234" },
|
||||
})
|
||||
expect(result?.data?.num).toEqual("1234")
|
||||
})
|
||||
})
|
||||
@@ -107,7 +97,6 @@ describe("config", () => {
|
||||
const resultFn = await config.getRemoteConfig({
|
||||
git: "https://github.com/chenasraf/simple-scaffold.git",
|
||||
logLevel: LogLevel.none,
|
||||
tmpPath: `/tmp/scaffold-config-${Date.now()}`,
|
||||
})
|
||||
const result = await resolve(resultFn, blankCliConf)
|
||||
expect(result).toEqual(blankCliConf)
|
||||
|
||||