regify 1.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/LICENSE +15 -0
- package/README.md +53 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -0
- package/dist/scripts/index.d.ts +21 -0
- package/dist/scripts/index.d.ts.map +1 -0
- package/dist/scripts/index.js +18 -0
- package/dist/scripts/index.js.map +1 -0
- package/dist/src/commands/generate.d.ts +14 -0
- package/dist/src/commands/generate.d.ts.map +1 -0
- package/dist/src/commands/generate.js +152 -0
- package/dist/src/commands/generate.js.map +1 -0
- package/dist/src/commands/init.d.ts +2 -0
- package/dist/src/commands/init.d.ts.map +1 -0
- package/dist/src/commands/init.js +29 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/constant/current-version.d.ts +2 -0
- package/dist/src/constant/current-version.d.ts.map +1 -0
- package/dist/src/constant/current-version.js +2 -0
- package/dist/src/constant/current-version.js.map +1 -0
- package/dist/src/constant/registry-structure.d.ts +3 -0
- package/dist/src/constant/registry-structure.d.ts.map +1 -0
- package/dist/src/constant/registry-structure.js +9 -0
- package/dist/src/constant/registry-structure.js.map +1 -0
- package/dist/src/schema/generate.d.ts +19 -0
- package/dist/src/schema/generate.d.ts.map +1 -0
- package/dist/src/schema/generate.js +42 -0
- package/dist/src/schema/generate.js.map +1 -0
- package/dist/src/types/index.d.ts +79 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +2 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/utils/detect-registry-type.d.ts +28 -0
- package/dist/src/utils/detect-registry-type.d.ts.map +1 -0
- package/dist/src/utils/detect-registry-type.js +134 -0
- package/dist/src/utils/detect-registry-type.js.map +1 -0
- package/dist/src/utils/generate-registry.d.ts +9 -0
- package/dist/src/utils/generate-registry.d.ts.map +1 -0
- package/dist/src/utils/generate-registry.js +215 -0
- package/dist/src/utils/generate-registry.js.map +1 -0
- package/dist/src/utils/logger.d.ts +4 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/logger.js +9 -0
- package/dist/src/utils/logger.js.map +1 -0
- package/dist/src/utils/read-config.d.ts +3 -0
- package/dist/src/utils/read-config.d.ts.map +1 -0
- package/dist/src/utils/read-config.js +10 -0
- package/dist/src/utils/read-config.js.map +1 -0
- package/dist/src/utils/save-file.d.ts +3 -0
- package/dist/src/utils/save-file.d.ts.map +1 -0
- package/dist/src/utils/save-file.js +18 -0
- package/dist/src/utils/save-file.js.map +1 -0
- package/dist/src/utils/validate-options.d.ts +3 -0
- package/dist/src/utils/validate-options.d.ts.map +1 -0
- package/dist/src/utils/validate-options.js +23 -0
- package/dist/src/utils/validate-options.js.map +1 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yashraj
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# regify
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/regify)
|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
**Turn your components into shareable registries.**
|
|
7
|
+
|
|
8
|
+
`regify` is a powerful CLI tool and programmatic API that transforms your UI components, hooks, and libraries into JSON registries compatible with modern CLI tools (like ShadCN CLI). It automatically handles dependency detection, type classification, and file structure analysis.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- 🚀 **CLI & Programmatic API**: Use it in your terminal or integrate it into your apps.
|
|
13
|
+
- 📂 **Directory & File Support**: Process individual files or entire component directories.
|
|
14
|
+
- 🔍 **Smart Dependency Detection**: Automatically identifies NPM and local workspace dependencies.
|
|
15
|
+
- 🏷️ **Type Classification**: Detects if a file is a UI component, Hook, Lib, or Style.
|
|
16
|
+
- ⚙️ **Configurable**: Use `regify.json` to define output directories and dependency mappings.
|
|
17
|
+
- 🛠️ **Built with ts-morph**: High-fidelity analysis of your TypeScript/JavaScript source code.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install -g regify
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start (CLI)
|
|
26
|
+
|
|
27
|
+
1. **Initialize Config**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
regify init
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
2. **Generate Registry**:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
regify generate --input ./src/components/ui/Button.tsx
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Programmatic Usage
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { regify } from "regify";
|
|
43
|
+
|
|
44
|
+
const result = await regify("./src/components/ui", {
|
|
45
|
+
output: "./registry"
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
console.log(result.message);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
ISC
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { program } from "commander";
|
|
3
|
+
import { initAction } from "./src/commands/init.js";
|
|
4
|
+
import logger from "./src/utils/logger.js";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import { CURRENT_VERSION } from "./src/constant/current-version.js";
|
|
7
|
+
import { usingCLI } from "./src/commands/generate.js";
|
|
8
|
+
program
|
|
9
|
+
.name("regify")
|
|
10
|
+
.version(CURRENT_VERSION)
|
|
11
|
+
.description("Turn components into shareable registries that compatible with ShadCN CLI.");
|
|
12
|
+
// Initialization command
|
|
13
|
+
program
|
|
14
|
+
.command("init")
|
|
15
|
+
.description("Initialize regify configuration file")
|
|
16
|
+
.action(initAction);
|
|
17
|
+
// Generate command
|
|
18
|
+
program
|
|
19
|
+
.command("generate")
|
|
20
|
+
.description("Generate a registry.json file for the given component or directory of components")
|
|
21
|
+
.option("--name <name>", "Name of the component")
|
|
22
|
+
.option("--input <input>", "Relative path to the component file or directory. For directory path --name flag will be ignored.")
|
|
23
|
+
.option("--output [output]", "Output path for the generated JSON(s). Defaults to the current directory.")
|
|
24
|
+
.option("--rawjson", "Output raw JSON to console. If true, the --output flag will be ignored.")
|
|
25
|
+
.action((options) => usingCLI(options))
|
|
26
|
+
.configureOutput({
|
|
27
|
+
writeErr: () => { },
|
|
28
|
+
})
|
|
29
|
+
.exitOverride((err) => {
|
|
30
|
+
// it ignores the "Help" and "Version" calls (they aren't actual errors)
|
|
31
|
+
if (err.code === "commander.helpDisplayed" ||
|
|
32
|
+
err.code === "commander.version") {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
// formatting the known commander errors
|
|
36
|
+
// commander sometimes prepends "CommanderError:" and "error:" to the error message
|
|
37
|
+
logger.error(chalk.red(err.message.replace("error: ", "").replace("CommanderError: ", "") +
|
|
38
|
+
"\n"));
|
|
39
|
+
process.exit(err.exitCode);
|
|
40
|
+
});
|
|
41
|
+
try {
|
|
42
|
+
await program.parseAsync(process.argv);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
// This catches unexpected "Unknown" errors from processes and other internal actions
|
|
46
|
+
logger.error("An unexpected error occurred:");
|
|
47
|
+
console.log(chalk.dim(err.stack));
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,OAAO,CAAC,eAAe,CAAC;KACxB,WAAW,CACV,4EAA4E,CAC7E,CAAC;AAEJ,yBAAyB;AACzB,OAAO;KACJ,OAAO,CAAC,MAAM,CAAC;KACf,WAAW,CAAC,sCAAsC,CAAC;KACnD,MAAM,CAAC,UAAU,CAAC,CAAC;AAEtB,mBAAmB;AACnB,OAAO;KACJ,OAAO,CAAC,UAAU,CAAC;KACnB,WAAW,CACV,kFAAkF,CACnF;KACA,MAAM,CAAC,eAAe,EAAE,uBAAuB,CAAC;KAChD,MAAM,CACL,iBAAiB,EACjB,mGAAmG,CACpG;KACA,MAAM,CACL,mBAAmB,EACnB,2EAA2E,CAC5E;KACA,MAAM,CACL,WAAW,EACX,yEAAyE,CAC1E;KACA,MAAM,CAAC,CAAC,OAA2B,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;KAC1D,eAAe,CAAC;IACf,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;CACnB,CAAC;KACD,YAAY,CAAC,CAAC,GAAG,EAAE,EAAE;IACpB,wEAAwE;IACxE,IACE,GAAG,CAAC,IAAI,KAAK,yBAAyB;QACtC,GAAG,CAAC,IAAI,KAAK,mBAAmB,EAChC,CAAC;QACD,OAAO;IACT,CAAC;IAED,wCAAwC;IACxC,mFAAmF;IACnF,MAAM,CAAC,KAAK,CACV,KAAK,CAAC,GAAG,CACP,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;QAChE,IAAI,CACP,CACF,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC7B,CAAC,CAAC,CAAC;AAEL,IAAI,CAAC;IACH,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,qFAAqF;IACrF,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAE,GAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RawGenerateOptions } from "../src/types/index.js";
|
|
2
|
+
import { CURRENT_VERSION } from "../src/constant/current-version.js";
|
|
3
|
+
export { CURRENT_VERSION };
|
|
4
|
+
/**
|
|
5
|
+
* Programmatically run the regify generation process.
|
|
6
|
+
*
|
|
7
|
+
* @param input - Path to the component file or directory
|
|
8
|
+
* @param options - Additional generation options (flags)
|
|
9
|
+
* @returns Promise that resolves to a status object
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const result = await regify("./components/Button.tsx", { name: "MyButton" });
|
|
13
|
+
* console.log(result.message);
|
|
14
|
+
*/
|
|
15
|
+
export declare function regify(input: string, options?: Omit<RawGenerateOptions, "input">): Promise<{
|
|
16
|
+
status: boolean;
|
|
17
|
+
message: string;
|
|
18
|
+
data?: string;
|
|
19
|
+
}>;
|
|
20
|
+
export type { RawGenerateOptions, RegifyConfig, RegistryJson, RegistryFile, RegistryType, } from "../src/types/index.js";
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../scripts/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B;;;;;;;;;;GAUG;AACH,wBAAsB,MAAM,CAC1B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAM;;;;GAGhD;AAGD,YAAY,EACV,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { usingAPI } from "../src/commands/generate.js";
|
|
2
|
+
import { CURRENT_VERSION } from "../src/constant/current-version.js";
|
|
3
|
+
export { CURRENT_VERSION };
|
|
4
|
+
/**
|
|
5
|
+
* Programmatically run the regify generation process.
|
|
6
|
+
*
|
|
7
|
+
* @param input - Path to the component file or directory
|
|
8
|
+
* @param options - Additional generation options (flags)
|
|
9
|
+
* @returns Promise that resolves to a status object
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const result = await regify("./components/Button.tsx", { name: "MyButton" });
|
|
13
|
+
* console.log(result.message);
|
|
14
|
+
*/
|
|
15
|
+
export async function regify(input, options = {}) {
|
|
16
|
+
return await usingAPI({ ...options, input });
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../scripts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,KAAa,EACb,UAA6C,EAAE;IAE/C,OAAO,MAAM,QAAQ,CAAC,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RawGenerateOptions } from "../types/index.js";
|
|
2
|
+
declare function usingCLI(options: RawGenerateOptions): Promise<void>;
|
|
3
|
+
/**
|
|
4
|
+
* This function is used when you want to use regify as a library in your project.
|
|
5
|
+
* @param options - The options to use for generating the registry.
|
|
6
|
+
* @returns A promise that resolves to an object with the status, message, and data (optional).
|
|
7
|
+
*/
|
|
8
|
+
declare function usingAPI(options: RawGenerateOptions): Promise<{
|
|
9
|
+
status: boolean;
|
|
10
|
+
message: string;
|
|
11
|
+
data?: string;
|
|
12
|
+
}>;
|
|
13
|
+
export { usingCLI, usingAPI };
|
|
14
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAgB,MAAM,mBAAmB,CAAC;AAsHrE,iBAAe,QAAQ,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4ClE;AAED;;;;GAIG;AAEH,iBAAe,QAAQ,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC;IAC5D,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC,CASD;AAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import logger from "../utils/logger.js";
|
|
2
|
+
import { readConfig } from "../utils/read-config.js";
|
|
3
|
+
import { validateOptions } from "../utils/validate-options.js";
|
|
4
|
+
import { generateRegistry } from "../utils/generate-registry.js";
|
|
5
|
+
import { saveFile } from "../utils/save-file.js";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import fs from "fs";
|
|
8
|
+
import { globSync } from "glob";
|
|
9
|
+
import ora from "ora";
|
|
10
|
+
// Supported extensions for the file path
|
|
11
|
+
const SUPPORTED_EXTENSIONS = [".jsx", ".tsx", ".ts", ".js"];
|
|
12
|
+
async function starter(options) {
|
|
13
|
+
try {
|
|
14
|
+
// get config data (if available)
|
|
15
|
+
const CONFIG = await readConfig();
|
|
16
|
+
// get output directory from config or options
|
|
17
|
+
options.output = options.output || CONFIG.outputDir;
|
|
18
|
+
// resolve input
|
|
19
|
+
const resolvedInputPath = path.resolve(options.input);
|
|
20
|
+
// check if input is directory or file
|
|
21
|
+
const isDirectory = fs.statSync(resolvedInputPath).isDirectory();
|
|
22
|
+
if (isDirectory) {
|
|
23
|
+
const resolvedOutputPath = options.output
|
|
24
|
+
? path.resolve(options.output)
|
|
25
|
+
: path.resolve(resolvedInputPath, "registry");
|
|
26
|
+
const filesSearchPattern = `*{${SUPPORTED_EXTENSIONS.join(",")}}`;
|
|
27
|
+
const files = globSync(filesSearchPattern, {
|
|
28
|
+
cwd: resolvedInputPath,
|
|
29
|
+
nodir: true,
|
|
30
|
+
absolute: true,
|
|
31
|
+
});
|
|
32
|
+
const outputResults = [];
|
|
33
|
+
const savedPaths = [];
|
|
34
|
+
files.forEach((file) => {
|
|
35
|
+
const registry = generateRegistry(file, CONFIG);
|
|
36
|
+
if (options.rawjson) {
|
|
37
|
+
outputResults.push(registry);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const savedPath = saveFile(registry, resolvedOutputPath, `${path.basename(file).split(".").shift()}.json`);
|
|
41
|
+
savedPaths.push(savedPath);
|
|
42
|
+
if (options.onFileProcessed)
|
|
43
|
+
options.onFileProcessed(savedPath);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
status: true,
|
|
48
|
+
message: "Registry generated successfully.",
|
|
49
|
+
data: options.rawjson
|
|
50
|
+
? JSON.stringify(outputResults, null, 2)
|
|
51
|
+
: JSON.stringify(savedPaths),
|
|
52
|
+
dataCount: savedPaths.length,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const resolvedOutputPath = options.output
|
|
57
|
+
? path.resolve(options.output)
|
|
58
|
+
: path.dirname(resolvedInputPath);
|
|
59
|
+
const registry = generateRegistry(resolvedInputPath, CONFIG);
|
|
60
|
+
if (options.rawjson) {
|
|
61
|
+
return {
|
|
62
|
+
status: true,
|
|
63
|
+
message: "Registry generated successfully.",
|
|
64
|
+
data: JSON.stringify(registry, null, 2),
|
|
65
|
+
dataCount: 1,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const finalFileName = (options.name || path.basename(resolvedInputPath))
|
|
70
|
+
.split(".")
|
|
71
|
+
.shift() + ".json";
|
|
72
|
+
const savedPath = saveFile(registry, resolvedOutputPath, finalFileName);
|
|
73
|
+
if (options.onFileProcessed)
|
|
74
|
+
options.onFileProcessed(savedPath);
|
|
75
|
+
return {
|
|
76
|
+
status: true,
|
|
77
|
+
message: "Registry generated successfully.",
|
|
78
|
+
data: JSON.stringify([savedPath]),
|
|
79
|
+
dataCount: 1,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
return {
|
|
86
|
+
status: false,
|
|
87
|
+
message: err.message || err,
|
|
88
|
+
dataCount: 0,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async function usingCLI(options) {
|
|
93
|
+
try {
|
|
94
|
+
const parsedOptions = validateOptions(options);
|
|
95
|
+
// Extract
|
|
96
|
+
const { name, input, rawjson, output } = parsedOptions;
|
|
97
|
+
const spinner = !rawjson
|
|
98
|
+
? ora("Initializing registry generation...").start()
|
|
99
|
+
: null;
|
|
100
|
+
const response = await starter({
|
|
101
|
+
name,
|
|
102
|
+
input,
|
|
103
|
+
rawjson,
|
|
104
|
+
output,
|
|
105
|
+
onFileProcessed: (p) => {
|
|
106
|
+
if (spinner) {
|
|
107
|
+
spinner.text = `Processing: ${p}`;
|
|
108
|
+
// To keep a persistent log of saved files above the spinner
|
|
109
|
+
ora().succeed(`Saved to - ${p}`);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
if (response.status) {
|
|
114
|
+
if (rawjson && response.data) {
|
|
115
|
+
console.log(response.data);
|
|
116
|
+
}
|
|
117
|
+
else if (spinner) {
|
|
118
|
+
spinner.succeed(response.dataCount > 1
|
|
119
|
+
? `All registries generated successfully! (${response.dataCount})`
|
|
120
|
+
: `Registry generated successfully!`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
if (spinner)
|
|
125
|
+
spinner.fail("Generation failed");
|
|
126
|
+
logger.error(response.message);
|
|
127
|
+
process.exit(1);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
logger.error(err.message || err);
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* This function is used when you want to use regify as a library in your project.
|
|
137
|
+
* @param options - The options to use for generating the registry.
|
|
138
|
+
* @returns A promise that resolves to an object with the status, message, and data (optional).
|
|
139
|
+
*/
|
|
140
|
+
async function usingAPI(options) {
|
|
141
|
+
try {
|
|
142
|
+
return await starter(options);
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
return {
|
|
146
|
+
status: false,
|
|
147
|
+
message: err.message || err,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
export { usingCLI, usingAPI };
|
|
152
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/commands/generate.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,yCAAyC;AACzC,MAAM,oBAAoB,GAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAUtE,KAAK,UAAU,OAAO,CAAC,OAAgB;IAMrC,IAAI,CAAC;QACH,iCAAiC;QACjC,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;QAElC,8CAA8C;QAC9C,OAAO,CAAC,MAAM,GAAG,OAAO,C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AI,CAAC,CAAC;YAC7B,CAAC;iBAAM,IAAI,OAAO,EAAE,CAAC;gBACnB,OAAO,CAAC,OAAO,CACb,QAAQ,CAAC,SAAS,GAAG,CAAC;oBACpB,CAAC,CAAC,2CAA2C,QAAQ,CAAC,SAAS,GAAG;oBAClE,CAAC,CAAC,kCAAkC,CACvC,CAAC;YACJ,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAI,OAAO;gBAAE,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YAC/C,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,KAAK,CAAE,GAAa,CAAC,OAAO,IAAK,GAAc,CAAC,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED;;;;GAIG;AAEH,KAAK,UAAU,QAAQ,CAAC,OAA2B;IAKjD,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,OAAkB,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO;YACL,MAAM,EAAE,KAAK;YACb,OAAO,EAAG,GAAa,CAAC,OAAO,IAAK,GAAc;SACnD,CAAC;IACJ,CAAC;AACH,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAOA,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CA8BhD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import logger from "../utils/logger.js";
|
|
5
|
+
import { CURRENT_VERSION } from "../constant/current-version.js";
|
|
6
|
+
export async function initAction() {
|
|
7
|
+
const configPath = path.resolve(process.cwd(), "regify.json");
|
|
8
|
+
if (fs.existsSync(configPath)) {
|
|
9
|
+
logger.warn("regify.json already exists in the current directory.");
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const defaultConfig = {
|
|
13
|
+
name: "regify",
|
|
14
|
+
version: CURRENT_VERSION,
|
|
15
|
+
registryDependencies: {},
|
|
16
|
+
outputDir: "./registry",
|
|
17
|
+
basePath: "src/components",
|
|
18
|
+
};
|
|
19
|
+
try {
|
|
20
|
+
fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2), "utf-8");
|
|
21
|
+
logger.success("✅ Created regify.json with default configuration.");
|
|
22
|
+
logger.info(`Now you can edit your ${chalk.cyan("regify.json")} config file.`);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
logger.error(`Failed to create regify.json: ${error.message}`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,CAAC;IAE9D,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC;QACpE,OAAO;IACT,CAAC;IAED,MAAM,aAAa,GAAiB;QAClC,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,eAAe;QACxB,oBAAoB,EAAE,EAAE;QACxB,SAAS,EAAE,YAAY;QACvB,QAAQ,EAAE,gBAAgB;KAC3B,CAAC;IAEF,IAAI,CAAC;QACH,EAAE,CAAC,aAAa,CACd,UAAU,EACV,IAAI,CAAC,SAAS,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC,EACtC,OAAO,CACR,CAAC;QACF,MAAM,CAAC,OAAO,CAAC,mDAAmD,CAAC,CAAC;QACpE,MAAM,CAAC,IAAI,CACT,yBAAyB,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,CAClE,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,iCAAkC,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-version.d.ts","sourceRoot":"","sources":["../../../src/constant/current-version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-version.js","sourceRoot":"","sources":["../../../src/constant/current-version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-structure.d.ts","sourceRoot":"","sources":["../../../src/constant/registry-structure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,eAAO,MAAM,iBAAiB,EAAE,iBAO/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-structure.js","sourceRoot":"","sources":["../../../src/constant/registry-structure.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAsB;IAClD,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,IAAI;IACV,YAAY,EAAE,IAAI,GAAG,EAAE;IACvB,eAAe,EAAE,IAAI,GAAG,EAAE;IAC1B,oBAAoB,EAAE,IAAI,GAAG,EAAE;IAC/B,KAAK,EAAE,EAAE;CACV,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const generateSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
4
|
+
input: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
5
|
+
output: z.ZodOptional<z.ZodString>;
|
|
6
|
+
rawjson: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
input: string;
|
|
9
|
+
name?: string | undefined;
|
|
10
|
+
output?: string | undefined;
|
|
11
|
+
rawjson?: boolean | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
input: string;
|
|
14
|
+
name?: string | undefined;
|
|
15
|
+
output?: string | undefined;
|
|
16
|
+
rawjson?: boolean | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export default generateSchema;
|
|
19
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/schema/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;EA8ClB,CAAC;AAEH,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
const generateSchema = z.object({
|
|
5
|
+
name: z
|
|
6
|
+
.string()
|
|
7
|
+
.refine((val) => {
|
|
8
|
+
if (!val)
|
|
9
|
+
return true;
|
|
10
|
+
const trimmed = val.trim();
|
|
11
|
+
// Check if not empty and doesn't start with a number
|
|
12
|
+
return trimmed.length > 0 && !/^\d/.test(trimmed);
|
|
13
|
+
}, {
|
|
14
|
+
message: "Component name must not start with a number",
|
|
15
|
+
})
|
|
16
|
+
.optional(),
|
|
17
|
+
input: z
|
|
18
|
+
.string({ required_error: "Component path is required" })
|
|
19
|
+
.refine((val) => {
|
|
20
|
+
const fullPath = path.resolve(val);
|
|
21
|
+
// Check if path exists
|
|
22
|
+
return fs.existsSync(fullPath);
|
|
23
|
+
}, {
|
|
24
|
+
message: "Path must exist",
|
|
25
|
+
})
|
|
26
|
+
.refine((val) => {
|
|
27
|
+
const fullPath = path.resolve(val);
|
|
28
|
+
const stats = fs.statSync(fullPath);
|
|
29
|
+
// If it's a directory, it's valid
|
|
30
|
+
if (stats.isDirectory())
|
|
31
|
+
return true;
|
|
32
|
+
// If it's a file, check the extension
|
|
33
|
+
const ext = path.extname(val);
|
|
34
|
+
return [".jsx", ".tsx", ".ts", ".js"].includes(ext);
|
|
35
|
+
}, {
|
|
36
|
+
message: "Path must be a directory or a file with extension .jsx, .tsx, .ts, or .js",
|
|
37
|
+
}),
|
|
38
|
+
output: z.string().optional(),
|
|
39
|
+
rawjson: z.boolean().optional(),
|
|
40
|
+
});
|
|
41
|
+
export default generateSchema;
|
|
42
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../src/schema/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,cAAc,G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E,CAAC,QAAQ,EAAE;IAC7B,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CAChC,CAAC,CAAC;AAEH,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type generateSchema from "../schema/generate.js";
|
|
3
|
+
/**
|
|
4
|
+
* Registry types for component classification
|
|
5
|
+
*/
|
|
6
|
+
export type RegistryType = "registry:ui" | "registry:hook" | "registry:lib" | "registry:style";
|
|
7
|
+
/**
|
|
8
|
+
* File entry in the registry
|
|
9
|
+
*/
|
|
10
|
+
export interface RegistryFile {
|
|
11
|
+
path: string;
|
|
12
|
+
content: string;
|
|
13
|
+
type: RegistryType;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Registry structure (internal - with Sets)
|
|
17
|
+
*/
|
|
18
|
+
export interface RegistryStructure {
|
|
19
|
+
name: string;
|
|
20
|
+
type: RegistryType | null;
|
|
21
|
+
dependencies: Set<string>;
|
|
22
|
+
devDependencies: Set<string>;
|
|
23
|
+
registryDependencies: Set<string>;
|
|
24
|
+
files: RegistryFile[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Registry JSON output (external - with arrays)
|
|
28
|
+
*/
|
|
29
|
+
export interface RegistryJson {
|
|
30
|
+
name: string;
|
|
31
|
+
type: RegistryType | null;
|
|
32
|
+
dependencies: string[];
|
|
33
|
+
devDependencies: string[];
|
|
34
|
+
registryDependencies: string[];
|
|
35
|
+
files: RegistryFile[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generate command options (parsed)
|
|
39
|
+
*/
|
|
40
|
+
export type GenerateOptions = z.infer<typeof generateSchema>;
|
|
41
|
+
/**
|
|
42
|
+
* Command options from commander (raw)
|
|
43
|
+
*/
|
|
44
|
+
export interface RawGenerateOptions {
|
|
45
|
+
name?: string;
|
|
46
|
+
input?: string;
|
|
47
|
+
output?: string;
|
|
48
|
+
rawjson?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Regify configuration file structure
|
|
52
|
+
*/
|
|
53
|
+
export interface RegifyConfig {
|
|
54
|
+
name?: string;
|
|
55
|
+
version?: string;
|
|
56
|
+
outputDir?: string;
|
|
57
|
+
registryDependencies?: Record<string, string>;
|
|
58
|
+
basePath?: string;
|
|
59
|
+
[key: string]: unknown;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Workspace information for monorepo detection
|
|
63
|
+
*/
|
|
64
|
+
export interface WorkspaceInfo {
|
|
65
|
+
isMonorepo: boolean;
|
|
66
|
+
workspaces: string[];
|
|
67
|
+
dependencies: Set<string>;
|
|
68
|
+
workspaceDependencies: Set<string>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Logger interface
|
|
72
|
+
*/
|
|
73
|
+
export interface Logger {
|
|
74
|
+
error: (msg: string) => void;
|
|
75
|
+
success: (msg: string) => void;
|
|
76
|
+
info: (msg: string) => void;
|
|
77
|
+
warn: (msg: string) => void;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,cAAc,MAAM,uBAAuB,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB,aAAa,GACb,eAAe,GACf,cAAc,GACd,gBAAgB,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,YAAY,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,GAAG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C,MAAM,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { SourceFile } from "ts-morph";
|
|
2
|
+
import type { RegistryType } from "../types/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Registry type constants
|
|
5
|
+
*/
|
|
6
|
+
export declare const REGISTRY_TYPES: {
|
|
7
|
+
readonly UI: "registry:ui";
|
|
8
|
+
readonly HOOK: "registry:hook";
|
|
9
|
+
readonly LIB: "registry:lib";
|
|
10
|
+
readonly STYLE: "registry:style";
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Main function to detect registry type based on file path, name, and content
|
|
14
|
+
*
|
|
15
|
+
* Detection priority:
|
|
16
|
+
* 1. File extension (style files)
|
|
17
|
+
* 2. Naming convention (e.g., use-* for hooks)
|
|
18
|
+
* 3. Path-based detection (most reliable for organized projects)
|
|
19
|
+
* 4. Content analysis (for ambiguous cases)
|
|
20
|
+
* 5. Default fallback (lib)
|
|
21
|
+
*
|
|
22
|
+
* @param filePath - Absolute path to the file
|
|
23
|
+
* @param rootDir - Root directory of the project
|
|
24
|
+
* @param sourceFile - ts-morph SourceFile object (optional)
|
|
25
|
+
* @returns Registry type (e.g., "registry:ui")
|
|
26
|
+
*/
|
|
27
|
+
export declare function detectRegistryType(filePath: string, rootDir: string, sourceFile?: SourceFile | null): RegistryType;
|
|
28
|
+
//# sourceMappingURL=detect-registry-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-registry-type.d.ts","sourceRoot":"","sources":["../../../src/utils/detect-registry-type.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC;AAmFX;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,UAAU,GAAE,UAAU,GAAG,IAAW,GACnC,YAAY,CA0Cd"}
|