mirror of
https://github.com/chenasraf/simple-scaffold.git
synced 2026-05-17 17:28:09 +00:00
chore: cleanup
This commit is contained in:
@@ -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} */
|
||||
|
||||
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