simple-scaffold 2.3.3 → 3.0.0

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/cmd.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cmd.js","sourceRoot":"","sources":["../src/cmd.ts"],"names":[],"mappings":";;;;;;AAaA,oCA8PC;AAzQD,0DAA4B;AAC5B,gEAAiC;AACjC,qCAAiC;AACjC,mCAA4E;AAC5E,yCAAqC;AACrC,qCAA0E;AAC1E,qCAA8B;AAC9B,6CAAgD;AAChD,iCAAkE;AAClE,mCAAkC;AAE3B,KAAK,UAAU,YAAY,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7D,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,kBAAE,CAAC,IAAI,CAAC,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IACrG,MAAM,OAAO,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAA;IACtG,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC1C,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IACvE,MAAM,oBAAoB,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC7E,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,QAAQ,CA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AA8C,EAAE;SAC/E,CAAC,IAAI,CAAC,IAAI,CAAC;KACb,CAAC;SACD,KAAK,CAAC,IAAI,CAAC,CAAA;AAChB,CAAC;AAED,YAAY,EAAE,CAAA"}
1
+ {"version":3,"file":"cmd.js","names":[],"sources":["../src/cmd.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport path from \"node:path\"\nimport fs from \"node:fs/promises\"\nimport { massarg } from \"massarg\"\nimport { ListCommandCliOptions, LogLevel, ScaffoldCmdConfig, ScaffoldConfigMap } from \"./types\"\nimport { Scaffold } from \"./scaffold\"\nimport { findConfigFile, getConfigFile, parseAppendData, parseConfigFile } from \"./config\"\nimport { log } from \"./logger\"\nimport { MassargCommand } from \"massarg/command\"\nimport { getUniqueTmpPath as generateUniqueTmpPath } from \"./file\"\nimport { colorize } from \"./colors\"\nimport { promptForMissingConfig, resolveInputs } from \"./prompts\"\n\nexport async function parseCliArgs(args = process.argv.slice(2)) {\n const isProjectRoot = Boolean(await fs.stat(path.join(__dirname, \"package.json\")).catch(() => false))\n const pkgFile = await fs.readFile(path.resolve(__dirname, isProjectRoot ? \".\" : \"..\", \"package.json\"))\n const pkg = JSON.parse(pkgFile.toString())\n const isVersionFlag = args.includes(\"--version\") || args.includes(\"-v\")\n const isConfigFileProvided = args.includes(\"--config\") || args.includes(\"-c\")\n const isGitProvided = args.includes(\"--git\") || args.includes(\"-g\")\n const isConfigProvided = isConfigFileProvided || isGitProvided || isVersionFlag\n\n return massarg<ScaffoldCmdConfig>({\n name: pkg.name,\n description: pkg.description,\n })\n .main(async (config) => {\n if (config.version) {\n console.log(pkg.version)\n return\n }\n log(config, LogLevel.info, `Simple Scaffold v${pkg.version}`)\n config.tmpDir = generateUniqueTmpPath()\n try {\n // Auto-detect config file in cwd if not explicitly provided\n if (!config.config && !config.git) {\n try {\n config.config = await findConfigFile(process.cwd())\n log(config, LogLevel.debug, `Auto-detected config file: ${config.config}`)\n } catch {\n // No config file found — that's fine, continue without one\n }\n }\n\n // Load config early so we can prompt for template key\n const hasConfigSource = Boolean(config.config || config.git)\n let configMap: ScaffoldConfigMap | undefined\n if (hasConfigSource) {\n configMap = await getConfigFile(config)\n }\n\n // Prompt for missing values interactively\n config = await promptForMissingConfig(config, configMap)\n\n log(config, LogLevel.debug, \"Parsing config file...\", config)\n const parsed = await parseConfigFile(config)\n const resolved = await resolveInputs(parsed)\n await Scaffold(resolved)\n } catch (e) {\n const message = \"message\" in (e as object) ? (e as Error).message : e?.toString()\n log(config, LogLevel.error, message)\n } finally {\n log(config, LogLevel.debug, \"Cleaning up temporary files...\", config.tmpDir)\n if (config.tmpDir) await fs.rm(config.tmpDir, { recursive: true, force: true })\n }\n })\n .option({\n name: \"name\",\n aliases: [\"n\"],\n description:\n \"Name to be passed to the generated files. `{{name}}` and other data parameters inside \" +\n \"contents and file names will be replaced accordingly. You may omit the `--name` or `-n` \" +\n \"for this specific option. If omitted in an interactive terminal, you will be prompted.\",\n isDefault: true,\n })\n .option({\n name: \"config\",\n aliases: [\"c\"],\n description: \"Filename or directory to load config from\",\n })\n .option({\n name: \"git\",\n aliases: [\"g\"],\n description: \"Git URL or GitHub path to load a template from.\",\n })\n .option({\n name: \"key\",\n aliases: [\"k\"],\n description:\n \"Key to load inside the config file. This overwrites the config key provided after the colon in `--config` \" +\n \"(e.g. `--config scaffold.cmd.js:component)`. If omitted and multiple templates are available, \" +\n \"you will be prompted to select one.\",\n })\n .option({\n name: \"output\",\n aliases: [\"o\"],\n description:\n \"Path to output to. If `--subdir` is enabled, the subdir will be created inside \" +\n \"this path. If omitted in an interactive terminal, you will be prompted.\",\n })\n .option({\n name: \"templates\",\n aliases: [\"t\"],\n array: true,\n description:\n \"Template files to use as input. You may provide multiple files, each of which can be a relative or \" +\n \"absolute path, \" +\n \"or a glob pattern for multiple file matching easily. If omitted in an interactive terminal, \" +\n \"you will be prompted for a comma-separated list.\",\n })\n .flag({\n name: \"overwrite\",\n aliases: [\"w\"],\n defaultValue: false,\n description: \"Enable to override output files, even if they already exist.\",\n negatable: true,\n })\n .option({\n name: \"data\",\n aliases: [\"d\"],\n description: \"Add custom data to the templates. By default, only your app name is included.\",\n parse: (v) => JSON.parse(v),\n })\n .option({\n name: \"append-data\",\n aliases: [\"D\"],\n description:\n \"Append additional custom data to the templates, which will overwrite `--data`, using an alternate syntax, \" +\n \"which is easier to use with CLI: `-D key1=string -D key2:=raw`\",\n parse: parseAppendData,\n })\n .flag({\n name: \"subdir\",\n aliases: [\"s\"],\n defaultValue: false,\n description: \"Create a parent directory with the input name (and possibly `--subdir-helper`\",\n negatable: true,\n negationName: \"no-subdir\",\n })\n .option({\n name: \"subdir-helper\",\n aliases: [\"H\"],\n description: \"Default helper to apply to subdir name when using `--subdir`.\",\n })\n .flag({\n name: \"quiet\",\n aliases: [\"q\"],\n defaultValue: false,\n description: \"Suppress output logs (Same as `--log-level none`)\",\n })\n .option({\n name: \"log-level\",\n aliases: [\"l\"],\n defaultValue: LogLevel.info,\n description:\n \"Determine amount of logs to display. The values are: \" +\n `${colorize.bold`\\`none | debug | info | warn | error\\``}. ` +\n \"The provided level will display messages of the same level or higher.\",\n parse: (v) => {\n const val = v.toLowerCase()\n if (!(val in LogLevel)) {\n throw new Error(`Invalid log level: ${val}, must be one of: ${Object.keys(LogLevel).join(\", \")}`)\n }\n return val\n },\n })\n .option({\n name: \"before-write\",\n aliases: [\"B\"],\n description:\n \"Run a script before writing the files. This can be a command or a path to a\" +\n \" file. A temporary file path will be passed to the given command and the command should \" +\n \"return a string for the final output.\",\n })\n .flag({\n name: \"dry-run\",\n aliases: [\"dr\"],\n defaultValue: false,\n description:\n \"Don't emit files. This is good for testing your scaffolds and making sure they \" +\n \"don't fail, without having to write actual file contents or create directories.\",\n })\n .flag({\n name: \"version\",\n aliases: [\"v\"],\n description: \"Display version.\",\n })\n .command(\n new MassargCommand<ListCommandCliOptions>({\n name: \"list\",\n aliases: [\"ls\"],\n description: \"List all available templates for a given config. See `list -h` for more information.\",\n run: async (_config) => {\n const config = {\n templates: [],\n name: \"\",\n version: false,\n output: \"\",\n subdir: false,\n overwrite: false,\n dryRun: false,\n tmpDir: generateUniqueTmpPath(),\n ..._config,\n config: _config.config ?? (!_config.git ? process.cwd() : undefined),\n }\n try {\n const file = await getConfigFile(config)\n console.log(colorize.underline`Available templates:\\n`)\n console.log(Object.keys(file).join(\"\\n\"))\n } catch (e) {\n const message = \"message\" in (e as object) ? (e as Error).message : e?.toString()\n log(config, LogLevel.error, message)\n } finally {\n log(config, LogLevel.debug, \"Cleaning up temporary files...\", config.tmpDir)\n if (config.tmpDir) await fs.rm(config.tmpDir, { recursive: true, force: true })\n }\n },\n })\n .option({\n name: \"config\",\n aliases: [\"c\"],\n description: \"Filename or directory to load config from. Defaults to current working directory.\",\n })\n .option({\n name: \"git\",\n aliases: [\"g\"],\n description: \"Git URL or GitHub path to load a template from.\",\n })\n .option({\n name: \"log-level\",\n aliases: [\"l\"],\n defaultValue: LogLevel.none,\n description:\n \"Determine amount of logs to display. The values are: \" +\n `${colorize.bold`\\`none | debug | info | warn | error\\``}. ` +\n \"The provided level will display messages of the same level or higher.\",\n parse: (v) => {\n const val = v.toLowerCase()\n if (!(val in LogLevel)) {\n throw new Error(`Invalid log level: ${val}, must be one of: ${Object.keys(LogLevel).join(\", \")}`)\n }\n return val\n },\n })\n .help({\n bindOption: true,\n }),\n )\n .example({\n description: \"Usage with config file\",\n input: \"simple-scaffold -c scaffold.cmd.js --key component\",\n })\n .example({\n description: \"Usage with GitHub config file\",\n input: \"simple-scaffold -g chenasraf/simple-scaffold --key component\",\n })\n .example({\n description: \"Usage with https git URL (for non-GitHub)\",\n input: \"simple-scaffold -g https://example.com/user/template.git -c scaffold.cmd.js --key component\",\n })\n .example({\n description: \"Excluded template key, assumes 'default' key\",\n input: \"simple-scaffold -c scaffold.cmd.js MyComponent\",\n })\n .example({\n description:\n \"Shortest syntax for GitHub, searches for config file automaticlly, assumes and template key 'default'\",\n input: \"simple-scaffold -g chenasraf/simple-scaffold MyComponent\",\n })\n .help({\n bindOption: true,\n lineLength: 100,\n useGlobalTableColumns: true,\n usageText: [colorize.yellow`simple-scaffold`, colorize.gray`[options]`, colorize.cyan`<name>`].join(\" \"),\n optionOptions: {\n displayNegations: true,\n },\n footerText: [\n `Version: ${pkg.version}`,\n `Copyright © Chen Asraf 2017-${new Date().getFullYear()}`,\n ``,\n `Documentation: ${colorize.underline`https://chenasraf.github.io/simple-scaffold`}`,\n `NPM: ${colorize.underline`https://npmjs.com/package/simple-scaffold`}`,\n `GitHub: ${colorize.underline`https://github.com/chenasraf/simple-scaffold`}`,\n ].join(\"\\n\"),\n })\n .parse(args)\n}\n\nparseCliArgs()\n"],"mappings":";;;;;;;;;;AAcA,eAAsB,aAAa,OAAO,QAAQ,KAAK,MAAM,EAAE,EAAE;CAC/D,MAAM,gBAAgB,QAAQ,MAAM,iBAAA,QAAG,KAAK,UAAA,QAAK,KAAK,WAAW,eAAe,CAAC,CAAC,YAAY,MAAM,CAAC;CACrG,MAAM,UAAU,MAAM,iBAAA,QAAG,SAAS,UAAA,QAAK,QAAQ,WAAW,gBAAgB,MAAM,MAAM,eAAe,CAAC;CACtG,MAAM,MAAM,KAAK,MAAM,QAAQ,UAAU,CAAC;AACpB,MAAK,SAAS,YAAY,IAAI,KAAK,SAAS,KAAK;AAC1C,MAAK,SAAS,WAAW,IAAI,KAAK,SAAS,KAAK;AACvD,MAAK,SAAS,QAAQ,IAAI,KAAK,SAAS,KAAK;AAGnE,SAAA,GAAA,QAAA,SAAkC;EAChC,MAAM,IAAI;EACV,aAAa,IAAI;EAClB,CAAC,CACC,KAAK,OAAO,WAAW;AACtB,MAAI,OAAO,SAAS;AAClB,WAAQ,IAAI,IAAI,QAAQ;AACxB;;AAEF,mBAAA,IAAI,QAAQ,iBAAA,SAAS,MAAM,oBAAoB,IAAI,UAAU;AAC7D,SAAO,SAAS,iBAAA,kBAAuB;AACvC,MAAI;AAEF,OAAI,CAAC,OAAO,UAAU,CAAC,OAAO,IAC5B,KAAI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ACR,CAAC,CACD,KAAK;EACJ,YAAY;EACZ,YAAY;EACZ,uBAAuB;EACvB,WAAW;GAAC,iBAAA,SAAS,MAAM;GAAmB,iBAAA,SAAS,IAAI;GAAa,iBAAA,SAAS,IAAI;GAAS,CAAC,KAAK,IAAI;EACxG,eAAe,EACb,kBAAkB,MACnB;EACD,YAAY;GACV,aAAa,IAAI;GACjB,gDAA+B,IAAI,MAAM,EAAC,aAAa;GACvD;GACA,mBAAmB,iBAAA,SAAS,SAAS;GACrC,SAAS,iBAAA,SAAS,SAAS;GAC3B,YAAY,iBAAA,SAAS,SAAS;GAC/B,CAAC,KAAK,KAAK;EACb,CAAC,CACD,MAAM,KAAK;;AAGhB,cAAc"}
package/colors.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ /** ANSI color code mapping for terminal output. */
2
+ declare const colorMap: {
3
+ readonly reset: 0;
4
+ readonly dim: 2;
5
+ readonly bold: 1;
6
+ readonly italic: 3;
7
+ readonly underline: 4;
8
+ readonly red: 31;
9
+ readonly green: 32;
10
+ readonly yellow: 33;
11
+ readonly blue: 34;
12
+ readonly magenta: 35;
13
+ readonly cyan: 36;
14
+ readonly white: 37;
15
+ readonly gray: 90;
16
+ };
17
+ /** Available terminal color names. */
18
+ export type TermColor = keyof typeof colorMap;
19
+ declare function _colorize(text: string, color: TermColor): string;
20
+ declare const createColorize: (color: TermColor) => (template: TemplateStringsArray | unknown, ...params: unknown[]) => string;
21
+ type TemplateStringsFn = ReturnType<typeof createColorize> & ((text: string) => string);
22
+ type TemplateStringsFns = {
23
+ [key in TermColor]: TemplateStringsFn;
24
+ };
25
+ /**
26
+ * Colorize text for terminal output.
27
+ *
28
+ * Can be used as a function: `colorize("text", "red")`
29
+ * Or via named helpers: `colorize.red("text")` / `colorize.red\`template\``
30
+ */
31
+ export declare const colorize: typeof _colorize & TemplateStringsFns;
32
+ export {};
package/config.d.ts CHANGED
@@ -1,17 +1,19 @@
1
- import { ConfigLoadConfig, FileResponse, LogConfig, RemoteConfigLoadConfig, ScaffoldCmdConfig, ScaffoldConfig, ScaffoldConfigFile, ScaffoldConfigMap } from "./types";
2
- /** @internal */
3
- export declare function getOptionValueForFile<T>(config: ScaffoldConfig, filePath: string, fn: FileResponse<T>, defaultValue?: T): T;
4
- /** @internal */
1
+ import { ConfigLoadConfig, LogConfig, RemoteConfigLoadConfig, ScaffoldCmdConfig, ScaffoldConfig, ScaffoldConfigFile, ScaffoldConfigMap } from "./types";
2
+ export { getOptionValueForFile } from "./file";
3
+ /** Parses CLI append-data syntax (`key=value` or `key:=jsonValue`) into a data object. @internal */
5
4
  export declare function parseAppendData(value: string, options: ScaffoldCmdConfig): unknown;
6
- /** @internal */
5
+ /** Loads and resolves a config file (local or remote). @internal */
7
6
  export declare function getConfigFile(config: ScaffoldCmdConfig): Promise<ScaffoldConfigMap>;
8
- /** @internal */
7
+ /**
8
+ * Parses a CLI config into a full ScaffoldConfig by merging CLI args, config file values,
9
+ * and append-data overrides. @internal
10
+ */
9
11
  export declare function parseConfigFile(config: ScaffoldCmdConfig): Promise<ScaffoldConfig>;
10
- /** @internal */
12
+ /** Converts a GitHub shorthand (user/repo) to a full HTTPS git URL. @internal */
11
13
  export declare function githubPartToUrl(part: string): string;
12
- /** @internal */
14
+ /** Loads a scaffold config from a local file or directory. @internal */
13
15
  export declare function getLocalConfig(config: ConfigLoadConfig & Partial<LogConfig>): Promise<ScaffoldConfigFile>;
14
- /** @internal */
16
+ /** Loads a scaffold config from a remote git repository. @internal */
15
17
  export declare function getRemoteConfig(config: RemoteConfigLoadConfig & Partial<LogConfig>): Promise<ScaffoldConfigFile>;
16
- /** @internal */
18
+ /** Searches for a scaffold config file in the given directory, trying known filenames in order. @internal */
17
19
  export declare function findConfigFile(root: string): Promise<string>;
package/file.d.ts CHANGED
@@ -1,19 +1,30 @@
1
- import { LogConfig, ScaffoldConfig } from "./types";
2
- export declare function createDirIfNotExists(dir: string, config: LogConfig & Pick<ScaffoldConfig, "dryRun">): Promise<void>;
3
- export declare function pathExists(filePath: string): Promise<boolean>;
4
- export declare function isDir(path: string): Promise<boolean>;
5
- export declare function removeGlob(template: string): string;
6
- export declare function makeRelativePath(str: string): string;
7
- export declare function getBasePath(relPath: string): string;
8
- export declare function getFileList(config: ScaffoldConfig, templates: string[]): Promise<string[]>;
1
+ import { FileResponse, ScaffoldConfig } from "./types";
2
+ export { createDirIfNotExists, pathExists, isDir, getUniqueTmpPath } from "./fs-utils";
3
+ export { removeGlob, makeRelativePath, getBasePath } from "./path-utils";
4
+ /**
5
+ * Resolves a config option that may be either a static value or a per-file function.
6
+ * For function values, the file path is parsed through Handlebars before being passed.
7
+ * @internal
8
+ */
9
+ export declare function getOptionValueForFile<T>(config: ScaffoldConfig, filePath: string, fn: FileResponse<T>, defaultValue?: T): T;
10
+ /** Information about a template glob pattern and how it was resolved. */
9
11
  export interface GlobInfo {
10
- nonGlobTemplate: string;
12
+ /** The template path with glob wildcards stripped. */
13
+ baseTemplatePath: string;
14
+ /** The original template string as provided by the user. */
11
15
  origTemplate: string;
16
+ /** Whether the template is a directory or contains glob patterns. */
12
17
  isDirOrGlob: boolean;
18
+ /** Whether the template contains glob wildcard characters. */
13
19
  isGlob: boolean;
20
+ /** The final resolved template path (with `**\/*` appended for directories). */
14
21
  template: string;
15
22
  }
23
+ /** Expands a list of glob patterns into a flat list of matching file paths. */
24
+ export declare function getFileList(config: ScaffoldConfig, templates: string[]): Promise<string[]>;
25
+ /** Analyzes a template path to determine if it's a glob, directory, or single file. */
16
26
  export declare function getTemplateGlobInfo(config: ScaffoldConfig, template: string): Promise<GlobInfo>;
27
+ /** Complete information about a template file's output destination. */
17
28
  export interface OutputFileInfo {
18
29
  inputPath: string;
19
30
  outputPathOpt: string;
@@ -21,20 +32,28 @@ export interface OutputFileInfo {
21
32
  outputPath: string;
22
33
  exists: boolean;
23
34
  }
35
+ /** Computes the full output path and metadata for a single template file. */
24
36
  export declare function getTemplateFileInfo(config: ScaffoldConfig, { templatePath, basePath }: {
25
37
  templatePath: string;
26
38
  basePath: string;
27
39
  }): Promise<OutputFileInfo>;
40
+ /**
41
+ * Reads a template file, applies Handlebars parsing, runs the beforeWrite hook,
42
+ * and writes the result to the output path.
43
+ */
28
44
  export declare function copyFileTransformed(config: ScaffoldConfig, { exists, overwrite, outputPath, inputPath, }: {
29
45
  exists: boolean;
30
46
  overwrite: boolean;
31
47
  outputPath: string;
32
48
  inputPath: string;
33
49
  }): Promise<void>;
50
+ /** Computes the output directory for a file, combining the output path, base path, and optional subdir. */
34
51
  export declare function getOutputDir(config: ScaffoldConfig, outputPathOpt: string, basePath: string): string;
52
+ /**
53
+ * Processes a single template file: resolves output paths, creates directories,
54
+ * and writes the transformed output.
55
+ */
35
56
  export declare function handleTemplateFile(config: ScaffoldConfig, { templatePath, basePath }: {
36
57
  templatePath: string;
37
58
  basePath: string;
38
59
  }): Promise<void>;
39
- /** @internal */
40
- export declare function getUniqueTmpPath(): string;
package/fs-utils.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { LogConfig, ScaffoldConfig } from "./types";
2
+ /** Recursively creates a directory and its parents if they don't exist. */
3
+ export declare function createDirIfNotExists(dir: string, config: LogConfig & Pick<ScaffoldConfig, "dryRun">): Promise<void>;
4
+ /** Checks whether a file or directory exists at the given path. */
5
+ export declare function pathExists(filePath: string): Promise<boolean>;
6
+ /** Returns true if the given path is a directory. */
7
+ export declare function isDir(dirPath: string): Promise<boolean>;
8
+ /** Generates a unique temporary directory path for scaffold operations. @internal */
9
+ export declare function getUniqueTmpPath(): string;
package/index.js CHANGED
@@ -1,24 +1,13 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- __exportStar(require("./scaffold"), exports);
21
- __exportStar(require("./types"), exports);
22
- const scaffold_1 = __importDefault(require("./scaffold"));
23
- exports.default = scaffold_1.default;
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
4
+ });
5
+ const require_scaffold = require("./scaffold-Ce-rIwy9.js");
6
+ //#region src/index.ts
7
+ var src_default = require_scaffold.Scaffold;
8
+ //#endregion
9
+ exports.LogLevel = require_scaffold.LogLevel;
10
+ exports.Scaffold = require_scaffold.Scaffold;
11
+ exports.default = src_default;
12
+
24
13
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,0CAAuB;AACvB,0DAAiC;AAEjC,kBAAe,kBAAQ,CAAA"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from \"./scaffold\"\nexport * from \"./types\"\nimport Scaffold from \"./scaffold\"\n\nexport default Scaffold\n"],"mappings":";;;;;;AAIA,IAAA,cAAe,iBAAA"}
package/logger.d.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  import { LogConfig, LogLevel, ScaffoldConfig } from "./types";
2
+ /** Logs a message at the given level, respecting the configured log level filter. */
2
3
  export declare function log(config: LogConfig, level: LogLevel, ...obj: unknown[]): void;
4
+ /**
5
+ * Logs detailed file processing information at debug level.
6
+ * @deprecated Use `log(config, LogLevel.debug, data)` directly instead.
7
+ */
3
8
  export declare function logInputFile(config: ScaffoldConfig, data: {
4
9
  originalTemplate: string;
5
10
  relativePath: string;
@@ -10,4 +15,5 @@ export declare function logInputFile(config: ScaffoldConfig, data: {
10
15
  isDirOrGlob: boolean;
11
16
  isGlob: boolean;
12
17
  }): void;
18
+ /** Logs the full scaffold configuration at debug level, with a data summary at info level. */
13
19
  export declare function logInitStep(config: ScaffoldConfig): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-scaffold",
3
- "version": "2.3.3",
3
+ "version": "3.0.0",
4
4
  "description": "Generate any file structure - from single components to entire app boilerplates, with a single command.",
5
5
  "homepage": "https://chenasraf.github.io/simple-scaffold",
6
6
  "repository": {
@@ -27,34 +27,36 @@
27
27
  ],
28
28
  "scripts": {
29
29
  "clean": "rimraf dist",
30
- "build": "pnpm clean && tsc && chmod -R +x ./dist && cp ./package.json ./README.md ./dist/",
31
- "dev": "tsc --watch",
32
- "start": "ts-node src/scaffold.ts",
33
- "test": "jest",
34
- "coverage": "open coverage/lcov-report/index.html",
35
- "cmd": "ts-node src/cmd.ts",
30
+ "build": "pnpm clean && vite build && tsc --emitDeclarationOnly && chmod -R +x ./dist && cp ./package.json ./README.md ./dist/",
31
+ "dev": "vite build --watch",
32
+ "start": "vite-node src/scaffold.ts",
33
+ "test": "vitest run",
34
+ "test:watch": "vitest",
35
+ "coverage": "vitest run --coverage && open coverage/lcov-report/index.html",
36
+ "cmd": "vite-node src/cmd.ts",
36
37
  "docs:build": "cd docs && pnpm build",
37
38
  "docs:watch": "cd docs && pnpm start",
38
39
  "audit-fix": "pnpm audit --fix",
39
40
  "ci": "pnpm install --frozen-lockfile"
40
41
  },
41
42
  "dependencies": {
43
+ "@inquirer/input": "^5.0.10",
44
+ "@inquirer/select": "^5.1.2",
42
45
  "date-fns": "^4.1.0",
43
- "glob": "^11.0.3",
46
+ "glob": "^13.0.6",
44
47
  "handlebars": "^4.7.8",
45
- "massarg": "2.0.1"
48
+ "massarg": "2.1.1"
46
49
  },
47
50
  "devDependencies": {
48
- "@eslint/js": "^9.29.0",
49
- "@types/jest": "^30.0.0",
50
- "@types/mock-fs": "^4.13.4",
51
- "@types/node": "^24.0.3",
52
- "jest": "^30.0.0",
51
+ "@eslint/js": "^10.0.1",
52
+ "@types/node": "^25.5.0",
53
+ "@vitest/coverage-v8": "^4.1.0",
53
54
  "mock-fs": "^5.5.0",
54
- "rimraf": "^6.0.1",
55
- "ts-jest": "^29.4.0",
56
- "ts-node": "^10.9.2",
57
- "typescript": "^5.8.3",
58
- "typescript-eslint": "^8.34.1"
55
+ "rimraf": "^6.1.3",
56
+ "typescript": "^5.9.3",
57
+ "typescript-eslint": "^8.57.1",
58
+ "vite": "^8.0.1",
59
+ "vite-node": "^6.0.0",
60
+ "vitest": "^4.1.0"
59
61
  }
60
62
  }
package/parser.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { DefaultHelpers, Helper, ScaffoldConfig } from "./types";
2
- import { Duration } from "date-fns";
2
+ import { type Duration } from "date-fns";
3
3
  export declare const defaultHelpers: Record<DefaultHelpers, Helper>;
4
4
  export declare function nowHelper(formatString: string): string;
5
5
  export declare function nowHelper(formatString: string, durationDifference: number, durationType: keyof Duration): string;
@@ -0,0 +1,6 @@
1
+ /** Strips glob wildcard characters from a template path. */
2
+ export declare function removeGlob(template: string): string;
3
+ /** Removes a leading path separator, making the path relative. */
4
+ export declare function makeRelativePath(str: string): string;
5
+ /** Computes a base path relative to the current working directory. */
6
+ export declare function getBasePath(relPath: string): string;
package/prompts.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import { ScaffoldCmdConfig, ScaffoldConfig, ScaffoldConfigMap, ScaffoldInput } from "./types";
2
+ /** Prompts the user for a scaffold name. */
3
+ export declare function promptForName(): Promise<string>;
4
+ /** Prompts the user to select a template key from the available config keys. */
5
+ export declare function promptForTemplateKey(configMap: ScaffoldConfigMap): Promise<string>;
6
+ /** Prompts the user for an output directory path. */
7
+ export declare function promptForOutput(): Promise<string>;
8
+ /** Prompts the user for template paths (comma-separated). */
9
+ export declare function promptForTemplates(): Promise<string[]>;
10
+ /**
11
+ * Prompts the user for any required scaffold inputs that are not already provided in data.
12
+ * Also applies default values for optional inputs that have one.
13
+ * Returns the merged data object.
14
+ */
15
+ export declare function promptForInputs(inputs: Record<string, ScaffoldInput>, existingData?: Record<string, unknown>): Promise<Record<string, unknown>>;
16
+ /** Returns true if the process is running in an interactive terminal. */
17
+ export declare function isInteractive(): boolean;
18
+ /**
19
+ * Fills in missing config values by prompting the user interactively.
20
+ * Only prompts when running in a TTY — in non-interactive mode, returns config as-is.
21
+ */
22
+ export declare function promptForMissingConfig(config: ScaffoldCmdConfig, configMap?: ScaffoldConfigMap): Promise<ScaffoldCmdConfig>;
23
+ /**
24
+ * Prompts for any required inputs defined in the scaffold config and merges them into data.
25
+ * Only prompts in interactive mode; in non-interactive mode, only applies defaults.
26
+ */
27
+ export declare function resolveInputs(config: ScaffoldConfig): Promise<ScaffoldConfig>;