Skip to content

Commit 9393c54

Browse files
committed
chore: cleanup
1 parent 263bf0b commit 9393c54

4 files changed

Lines changed: 16 additions & 39 deletions

File tree

release.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const releaseRules = [
77
{ type: "perf", section: "Misc", release: "patch" },
88
{ type: "build", section: "Build", release: "patch" },
99
{ type: "docs", section: "Build", release: false },
10-
{ type: "test", section: "Tests", release: false },
10+
{ type: "test", section: "Tests", release: "patch" },
1111
]
1212

1313
/** @type {import('semantic-release').Options} */

src/cmd.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import fs from "fs/promises"
88
import { parseAppendData, parseConfig } from "./config"
99

1010
export async function parseCliArgs(args = process.argv.slice(2)) {
11-
const pkg = JSON.parse((await fs.readFile(path.join(__dirname, "package.json"))).toString())
12-
const isConfig = args.includes("--config") || args.includes("-c") || args.includes("--github") || args.includes("-gh")
11+
const pkgFile = await fs.readFile(path.join(__dirname, "package.json"))
12+
const pkg = JSON.parse(pkgFile.toString())
13+
const isConfigProvided =
14+
args.includes("--config") || args.includes("-c") || args.includes("--github") || args.includes("-gh")
1315

1416
return (
1517
massarg<ScaffoldCmdConfig>()
@@ -47,7 +49,7 @@ export async function parseCliArgs(args = process.argv.slice(2)) {
4749
name: "output",
4850
aliases: ["o"],
4951
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)`}`}`,
50-
required: !isConfig,
52+
required: !isConfigProvided,
5153
})
5254
.option({
5355
name: "templates",
@@ -56,7 +58,7 @@ export async function parseCliArgs(args = process.argv.slice(2)) {
5658
description:
5759
"Template files to use as input. You may provide multiple files, each of which can be a relative or absolute path, " +
5860
"or a glob pattern for multiple file matching easily.",
59-
required: !isConfig,
61+
required: !isConfigProvided,
6062
})
6163
.option({
6264
name: "overwrite",

src/logger.ts

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,18 @@ export function log(config: LogConfig, level: LogLevel, ...obj: any[]): void {
3030

3131
export function logInputFile(
3232
config: ScaffoldConfig,
33-
{
34-
origTemplate,
35-
relPath,
36-
template,
37-
inputFilePath,
38-
nonGlobTemplate,
39-
basePath,
40-
isDirOrGlob,
41-
isGlob,
42-
}: {
43-
origTemplate: string
44-
relPath: string
45-
template: string
33+
data: {
34+
originalTemplate: string
35+
relativePath: string
36+
parsedTemplate: string
4637
inputFilePath: string
4738
nonGlobTemplate: string
4839
basePath: string
4940
isDirOrGlob: boolean
5041
isGlob: boolean
5142
},
5243
): void {
53-
log(
54-
config,
55-
LogLevel.Debug,
56-
`\nprocess.cwd(): ${process.cwd()}`,
57-
`\norigTemplate: ${origTemplate}`,
58-
`\nrelPath: ${relPath}`,
59-
`\ntemplate: ${template}`,
60-
`\ninputFilePath: ${inputFilePath}`,
61-
`\nnonGlobTemplate: ${nonGlobTemplate}`,
62-
`\nbasePath: ${basePath}`,
63-
`\nisDirOrGlob: ${isDirOrGlob}`,
64-
`\nisGlob: ${isGlob}`,
65-
`\n`,
66-
)
44+
log(config, LogLevel.Debug, data)
6745
}
6846

6947
export function logInitStep(config: ScaffoldConfig): void {

src/scaffold.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,19 @@
77
import path from "path"
88
import { handleErr, resolve } from "./utils"
99
import {
10-
createDirIfNotExists,
1110
isDir,
1211
removeGlob,
1312
makeRelativePath,
1413
getTemplateGlobInfo,
1514
getFileList,
1615
getBasePath,
17-
copyFileTransformed,
18-
getTemplateFileInfo,
1916
handleTemplateFile,
2017
} from "./file"
2118
import { LogLevel, MinimalConfig, Resolver, ScaffoldCmdConfig, ScaffoldConfig } from "./types"
2219
import { OptionsBase } from "massarg/types"
2320
import { pascalCase, registerHelpers } from "./parser"
2421
import { log, logInitStep, logInputFile } from "./logger"
25-
import { getOptionValueForFile, parseConfig } from "./config"
22+
import { parseConfig } from "./config"
2623

2724
/**
2825
* Create a scaffold using given `options`.
@@ -77,9 +74,9 @@ export async function Scaffold(config: ScaffoldConfig): Promise<void> {
7774
const relPath = makeRelativePath(path.dirname(removeGlob(inputFilePath).replace(nonGlobTemplate, "")))
7875
const basePath = getBasePath(relPath)
7976
logInputFile(config, {
80-
origTemplate,
81-
relPath,
82-
template,
77+
originalTemplate: origTemplate,
78+
relativePath: relPath,
79+
parsedTemplate: template,
8380
inputFilePath,
8481
nonGlobTemplate,
8582
basePath,

0 commit comments

Comments
 (0)