mirror of
https://github.com/chenasraf/simple-scaffold.git
synced 2026-05-18 01:29:09 +00:00
Compare commits
7 Commits
v1.7.0-dev
...
v1.7.0-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22763f655e | ||
|
|
a54b1f9fa7 | ||
|
|
dac5527173 | ||
|
|
339459cad8 | ||
|
|
62b4a1cd2f | ||
|
|
5844c080ec | ||
|
|
9393c546aa |
12
.github/workflows/docs.yml
vendored
12
.github/workflows/docs.yml
vendored
@@ -2,7 +2,7 @@ name: Documentation
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master, develop ]
|
||||
branches: [master, develop]
|
||||
jobs:
|
||||
docs:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -10,11 +10,13 @@ jobs:
|
||||
if: "!contains(github.event.head_commit.message, '[skip docs]')"
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
- uses: pnpm/action-setup@v2
|
||||
with:
|
||||
node-version: "18.x"
|
||||
- run: yarn install --frozen-lockfile
|
||||
- run: yarn build-docs
|
||||
# node-version: "18.x"
|
||||
run_install: |
|
||||
- recursive: true
|
||||
args: [--frozen-lockfile, --strict-peer-dependencies]
|
||||
- run: pnpm build-docs
|
||||
- uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
12
.github/workflows/pull_requests.yml
vendored
12
.github/workflows/pull_requests.yml
vendored
@@ -9,9 +9,11 @@ jobs:
|
||||
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
- uses: pnpm/action-setup@v2
|
||||
with:
|
||||
node-version: "18.x"
|
||||
- run: yarn install --frozen-lockfile
|
||||
- run: yarn build
|
||||
- run: yarn test
|
||||
# node-version: "18.x"
|
||||
run_install: |
|
||||
- recursive: true
|
||||
args: [--frozen-lockfile, --strict-peer-dependencies]
|
||||
- run: pnpm build
|
||||
- run: pnpm test
|
||||
|
||||
24
.github/workflows/release.yml
vendored
24
.github/workflows/release.yml
vendored
@@ -2,18 +2,20 @@ name: Test & Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master, develop, feat/*, fix/* ]
|
||||
branches: [master, develop, feat/*, fix/*]
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
- uses: pnpm/action-setup@v2
|
||||
with:
|
||||
node-version: "18.x"
|
||||
- run: yarn install --frozen-lockfile
|
||||
- run: yarn test
|
||||
# node-version: "18.x"
|
||||
run_install: |
|
||||
- recursive: true
|
||||
args: [--frozen-lockfile, --strict-peer-dependencies]
|
||||
- run: pnpm test
|
||||
if: "!contains(github.event.head_commit.message, '[skip test]')"
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -21,13 +23,15 @@ jobs:
|
||||
needs: test
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-node@v3
|
||||
- uses: pnpm/action-setup@v2
|
||||
with:
|
||||
node-version: "18.x"
|
||||
- run: yarn install --frozen-lockfile
|
||||
- run: yarn build
|
||||
- run: cd ./dist && yarn pack --filename=../package.tgz
|
||||
- run: yarn semantic-release
|
||||
run_install: |
|
||||
- recursive: true
|
||||
args: [--frozen-lockfile, --strict-peer-dependencies]
|
||||
- run: pnpm build
|
||||
- run: cd ./dist && pnpm pack --pack-destination=../
|
||||
- run: pnpm semantic-release
|
||||
if: "!contains(github.event.head_commit.message, '[skip publish]')"
|
||||
env:
|
||||
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Change Log
|
||||
|
||||
## [1.7.0-develop.3](https://github.com/chenasraf/simple-scaffold/compare/v1.7.0-develop.2...v1.7.0-develop.3) (2023-05-11)
|
||||
|
||||
## [1.7.0-develop.2](https://github.com/chenasraf/simple-scaffold/compare/v1.7.0-develop.1...v1.7.0-develop.2) (2023-05-10)
|
||||
|
||||
## [1.7.0-develop.1](https://github.com/chenasraf/simple-scaffold/compare/v1.6.0...v1.7.0-develop.1) (2023-05-09)
|
||||
|
||||
15
package.json
15
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "simple-scaffold",
|
||||
"version": "1.7.0-develop.2",
|
||||
"version": "1.7.0-develop.3",
|
||||
"description": "Generate any file structure - from single components to entire app boilerplates, with a single command.",
|
||||
"homepage": "https://chenasraf.github.io/simple-scaffold",
|
||||
"repository": "https://github.com/chenasraf/simple-scaffold.git",
|
||||
@@ -8,6 +8,7 @@
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"bin": "cmd.js",
|
||||
"packageManager": "pnpm@8.5.0",
|
||||
"keywords": [
|
||||
"javascript",
|
||||
"cli",
|
||||
@@ -21,17 +22,17 @@
|
||||
],
|
||||
"scripts": {
|
||||
"clean": "rimraf dist/",
|
||||
"build": "yarn clean && tsc && chmod -R +x ./dist && cp ./package.json ./README.md ./dist/",
|
||||
"build": "pnpm clean && tsc && chmod -R +x ./dist && cp ./package.json ./README.md ./dist/",
|
||||
"dev": "tsc --watch",
|
||||
"start": "node dist/scaffold.js",
|
||||
"test": "jest",
|
||||
"cmd": "node --trace-warnings dist/cmd.js",
|
||||
"build-test": "yarn build && yarn test",
|
||||
"build-cmd": "yarn build && yarn cmd",
|
||||
"build-test": "pnpm build && pnpm test",
|
||||
"build-cmd": "pnpm build && pnpm cmd",
|
||||
"build-docs": "typedoc",
|
||||
"watch-docs": "yarn typedoc --watch",
|
||||
"audit-fix": "npm_config_yes=true npx yarn-audit-fix --flow=convert",
|
||||
"changelog": "conventional-changelog -p conventionalcommits -i CHANGELOG.md -s -r 0"
|
||||
"watch-docs": "pnpm typedoc --watch",
|
||||
"audit-fix": "pnpm audit --fix",
|
||||
"changelog": "conventional-changelog -p conventionalcommits -i CHANGELOG.md -s -r 0; echo \"# Change Log\n\n$(cat CHANGELOG.md)\" > CHANGELOG.md"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^4.1.2",
|
||||
|
||||
@@ -7,7 +7,7 @@ const releaseRules = [
|
||||
{ type: "perf", section: "Misc", release: "patch" },
|
||||
{ type: "build", section: "Build", release: "patch" },
|
||||
{ type: "docs", section: "Build", release: false },
|
||||
{ type: "test", section: "Tests", release: false },
|
||||
{ type: "test", section: "Tests", release: "patch" },
|
||||
]
|
||||
|
||||
/** @type {import('semantic-release').Options} */
|
||||
@@ -77,7 +77,7 @@ module.exports = {
|
||||
[
|
||||
"@semantic-release/github",
|
||||
{
|
||||
assets: ["package.tgz"],
|
||||
assets: ["*.tgz"],
|
||||
},
|
||||
],
|
||||
],
|
||||
|
||||
10
src/cmd.ts
10
src/cmd.ts
@@ -8,8 +8,10 @@ import fs from "fs/promises"
|
||||
import { parseAppendData, parseConfig } from "./config"
|
||||
|
||||
export async function parseCliArgs(args = process.argv.slice(2)) {
|
||||
const pkg = JSON.parse((await fs.readFile(path.join(__dirname, "package.json"))).toString())
|
||||
const isConfig = args.includes("--config") || args.includes("-c") || args.includes("--github") || args.includes("-gh")
|
||||
const pkgFile = await fs.readFile(path.join(__dirname, "package.json"))
|
||||
const pkg = JSON.parse(pkgFile.toString())
|
||||
const isConfigProvided =
|
||||
args.includes("--config") || args.includes("-c") || args.includes("--github") || args.includes("-gh")
|
||||
|
||||
return (
|
||||
massarg<ScaffoldCmdConfig>()
|
||||
@@ -47,7 +49,7 @@ export async function parseCliArgs(args = process.argv.slice(2)) {
|
||||
name: "output",
|
||||
aliases: ["o"],
|
||||
description: `Path to output to. If --create-sub-folder is enabled, the subfolder will be created inside this path. ${chalk.reset`${chalk.white`(default: current dir)`}`}`,
|
||||
required: !isConfig,
|
||||
required: !isConfigProvided,
|
||||
})
|
||||
.option({
|
||||
name: "templates",
|
||||
@@ -56,7 +58,7 @@ export async function parseCliArgs(args = process.argv.slice(2)) {
|
||||
description:
|
||||
"Template files to use as input. You may provide multiple files, each of which can be a relative or absolute path, " +
|
||||
"or a glob pattern for multiple file matching easily.",
|
||||
required: !isConfig,
|
||||
required: !isConfigProvided,
|
||||
})
|
||||
.option({
|
||||
name: "overwrite",
|
||||
|
||||
@@ -30,19 +30,10 @@ export function log(config: LogConfig, level: LogLevel, ...obj: any[]): void {
|
||||
|
||||
export function logInputFile(
|
||||
config: ScaffoldConfig,
|
||||
{
|
||||
origTemplate,
|
||||
relPath,
|
||||
template,
|
||||
inputFilePath,
|
||||
nonGlobTemplate,
|
||||
basePath,
|
||||
isDirOrGlob,
|
||||
isGlob,
|
||||
}: {
|
||||
origTemplate: string
|
||||
relPath: string
|
||||
template: string
|
||||
data: {
|
||||
originalTemplate: string
|
||||
relativePath: string
|
||||
parsedTemplate: string
|
||||
inputFilePath: string
|
||||
nonGlobTemplate: string
|
||||
basePath: string
|
||||
@@ -50,20 +41,7 @@ export function logInputFile(
|
||||
isGlob: boolean
|
||||
},
|
||||
): void {
|
||||
log(
|
||||
config,
|
||||
LogLevel.Debug,
|
||||
`\nprocess.cwd(): ${process.cwd()}`,
|
||||
`\norigTemplate: ${origTemplate}`,
|
||||
`\nrelPath: ${relPath}`,
|
||||
`\ntemplate: ${template}`,
|
||||
`\ninputFilePath: ${inputFilePath}`,
|
||||
`\nnonGlobTemplate: ${nonGlobTemplate}`,
|
||||
`\nbasePath: ${basePath}`,
|
||||
`\nisDirOrGlob: ${isDirOrGlob}`,
|
||||
`\nisGlob: ${isGlob}`,
|
||||
`\n`,
|
||||
)
|
||||
log(config, LogLevel.Debug, data)
|
||||
}
|
||||
|
||||
export function logInitStep(config: ScaffoldConfig): void {
|
||||
|
||||
@@ -7,22 +7,19 @@
|
||||
import path from "path"
|
||||
import { handleErr, resolve } from "./utils"
|
||||
import {
|
||||
createDirIfNotExists,
|
||||
isDir,
|
||||
removeGlob,
|
||||
makeRelativePath,
|
||||
getTemplateGlobInfo,
|
||||
getFileList,
|
||||
getBasePath,
|
||||
copyFileTransformed,
|
||||
getTemplateFileInfo,
|
||||
handleTemplateFile,
|
||||
} from "./file"
|
||||
import { LogLevel, MinimalConfig, Resolver, ScaffoldCmdConfig, ScaffoldConfig } from "./types"
|
||||
import { OptionsBase } from "massarg/types"
|
||||
import { pascalCase, registerHelpers } from "./parser"
|
||||
import { log, logInitStep, logInputFile } from "./logger"
|
||||
import { getOptionValueForFile, parseConfig } from "./config"
|
||||
import { parseConfig } from "./config"
|
||||
|
||||
/**
|
||||
* Create a scaffold using given `options`.
|
||||
@@ -77,9 +74,9 @@ export async function Scaffold(config: ScaffoldConfig): Promise<void> {
|
||||
const relPath = makeRelativePath(path.dirname(removeGlob(inputFilePath).replace(nonGlobTemplate, "")))
|
||||
const basePath = getBasePath(relPath)
|
||||
logInputFile(config, {
|
||||
origTemplate,
|
||||
relPath,
|
||||
template,
|
||||
originalTemplate: origTemplate,
|
||||
relativePath: relPath,
|
||||
parsedTemplate: template,
|
||||
inputFilePath,
|
||||
nonGlobTemplate,
|
||||
basePath,
|
||||
|
||||
Reference in New Issue
Block a user