filtercn 0.1.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.
@@ -0,0 +1,7 @@
1
+ interface InitOptions {
2
+ force: boolean;
3
+ cwd: string;
4
+ }
5
+ export declare function initCommand(options: InitOptions): Promise<void>;
6
+ export {};
7
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAcA,UAAU,WAAW;IACnB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,iBA0GrD"}
@@ -0,0 +1,88 @@
1
+ import path from "node:path";
2
+ import chalk from "chalk";
3
+ import ora from "ora";
4
+ import prompts from "prompts";
5
+ import { detectProject } from "../utils/detect-project.js";
6
+ import { writeAllTemplates } from "../utils/file-writer.js";
7
+ import { checkPeerDependencies, installDependencies, getShadcnInstallHint, } from "../utils/dependencies.js";
8
+ import { getTemplateFiles } from "../templates/index.js";
9
+ import { logger } from "../utils/logger.js";
10
+ export async function initCommand(options) {
11
+ const cwd = path.resolve(options.cwd);
12
+ logger.title("🎛️ FilterCN — Component Installer");
13
+ // Step 1: Detect project
14
+ const spinner = ora("Detecting project structure...").start();
15
+ const projectInfo = detectProject(cwd);
16
+ spinner.succeed("Project detected");
17
+ console.log("");
18
+ console.log(chalk.dim(" Project root: ") + cwd);
19
+ console.log(chalk.dim(" Components dir: ") + projectInfo.componentsDir);
20
+ console.log(chalk.dim(" Package manager: ") + projectInfo.packageManager);
21
+ console.log(chalk.dim(" Import alias: ") + projectInfo.alias);
22
+ console.log("");
23
+ // Step 2: Confirm
24
+ const targetDir = path.join(projectInfo.componentsDir, "conditional-filter");
25
+ const { proceed } = await prompts({
26
+ type: "confirm",
27
+ name: "proceed",
28
+ message: `This will create files in ${chalk.cyan(targetDir)}. Continue?`,
29
+ initial: true,
30
+ });
31
+ if (!proceed) {
32
+ logger.info("Cancelled.");
33
+ return;
34
+ }
35
+ // Step 3: Write template files
36
+ logger.break();
37
+ const writeSpinner = ora("Scaffolding component files...").start();
38
+ const templates = getTemplateFiles(projectInfo.alias);
39
+ // Prefix each template path with the target directory
40
+ const prefixedTemplates = {};
41
+ for (const [relativePath, content] of Object.entries(templates)) {
42
+ prefixedTemplates[path.join(targetDir, relativePath)] = content;
43
+ }
44
+ writeSpinner.stop();
45
+ const fileCount = await writeAllTemplates(prefixedTemplates, {
46
+ cwd,
47
+ force: options.force,
48
+ });
49
+ logger.break();
50
+ logger.success(`${fileCount} files created.`);
51
+ // Step 4: Install peer dependencies
52
+ logger.break();
53
+ const missingDeps = checkPeerDependencies(cwd);
54
+ if (missingDeps.length > 0) {
55
+ const { installDeps } = await prompts({
56
+ type: "confirm",
57
+ name: "installDeps",
58
+ message: `Install missing dependencies (${missingDeps.join(", ")})?`,
59
+ initial: true,
60
+ });
61
+ if (installDeps) {
62
+ installDependencies(missingDeps, projectInfo, cwd);
63
+ }
64
+ else {
65
+ logger.warn("Skipped dependency installation. Install manually:");
66
+ logger.info(` ${missingDeps.join(" ")}`);
67
+ }
68
+ }
69
+ else {
70
+ logger.success("All peer dependencies already installed.");
71
+ }
72
+ // Step 5: Remind about shadcn/ui components
73
+ logger.break();
74
+ logger.info(chalk.yellow("Don't forget to install the required shadcn/ui components:"));
75
+ console.log("");
76
+ console.log(chalk.dim(" ") + chalk.cyan(getShadcnInstallHint(projectInfo.packageManager)));
77
+ console.log("");
78
+ // Done!
79
+ logger.break();
80
+ console.log(chalk.bold.green(" ✨ FilterCN installed successfully!"));
81
+ console.log("");
82
+ console.log(chalk.dim(" Quick start:"));
83
+ console.log("");
84
+ console.log(chalk.dim(" ") +
85
+ chalk.white(`import { FilterProvider, FilterRoot } from "${projectInfo.alias}components/conditional-filter";`));
86
+ console.log("");
87
+ }
88
+ //# sourceMappingURL=init.js.map
@@ -0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AAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC,CAAC;IACtE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC;QACf,KAAK,CAAC,KAAK,CAAC,+CAA+C,WAAW,CAAC,KAAK,iCAAiC,CAAC,CAC/G,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import { initCommand } from "./commands/init.js";
4
+ const program = new Command();
5
+ program
6
+ .name("filtercn")
7
+ .description("CLI to scaffold the FilterCN conditional filter component into your project")
8
+ .version("0.1.0");
9
+ program
10
+ .command("init")
11
+ .description("Initialize the conditional-filter component in your project")
12
+ .option("-f, --force", "Overwrite existing files", false)
13
+ .option("-c, --cwd <path>", "The working directory (defaults to current directory)", process.cwd())
14
+ .action(async (opts) => {
15
+ await initCommand({
16
+ force: opts.force,
17
+ cwd: opts.cwd,
18
+ });
19
+ });
20
+ program.parse();
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,6EAA6E,CAAC;KAC1F,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,6DAA6D,CAAC;KAC1E,MAAM,CAAC,aAAa,EAAE,0BAA0B,EAAE,KAAK,CAAC;KACxD,MAAM,CACL,kBAAkB,EAClB,uDAAuD,EACvD,OAAO,CAAC,GAAG,EAAE,CACd;KACA,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IACrB,MAAM,WAAW,CAAC;QAChB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,GAAG,EAAE,IAAI,CAAC,GAAG;KACd,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * All template files for the conditional-filter component.
3
+ * Each key is the relative path within the component directory,
4
+ * and each value is the file content.
5
+ *
6
+ * The `ALIAS` placeholder is replaced with the user's actual import alias.
7
+ */
8
+ /**
9
+ * Returns all template files mapped to their relative paths
10
+ * within the component directory. The alias placeholder will
11
+ * be replaced by the init command.
12
+ */
13
+ export declare function getTemplateFiles(alias: string): Record<string, string>;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA0oBH;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAmBtE"}