dcntui 0.1.9 → 0.1.10
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/dist/commands/add.d.ts +1 -1
- package/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +24 -95
- package/dist/commands/add.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +30 -7
- package/dist/commands/init.js.map +1 -1
- package/dist/constants.d.ts +1 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -2
- package/dist/constants.js.map +1 -1
- package/dist/index.js +9 -24
- package/dist/index.js.map +1 -1
- package/dist/utils/banner.d.ts.map +1 -1
- package/dist/utils/banner.js +7 -10
- package/dist/utils/banner.js.map +1 -1
- package/dist/utils/config.d.ts +0 -4
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +22 -21
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/detect-css.d.ts +2 -3
- package/dist/utils/detect-css.d.ts.map +1 -1
- package/dist/utils/detect-css.js +5 -114
- package/dist/utils/detect-css.js.map +1 -1
- package/dist/utils/detect-framework.d.ts.map +1 -1
- package/dist/utils/detect-framework.js +2 -9
- package/dist/utils/detect-framework.js.map +1 -1
- package/dist/utils/detect-package-manager.d.ts.map +1 -1
- package/dist/utils/detect-package-manager.js +15 -25
- package/dist/utils/detect-package-manager.js.map +1 -1
- package/dist/utils/detect-typescript.d.ts.map +1 -1
- package/dist/utils/detect-typescript.js +1 -7
- package/dist/utils/detect-typescript.js.map +1 -1
- package/dist/utils/helpers.d.ts +5 -3
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/utils/helpers.js +3 -3
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/registry.d.ts +3 -35
- package/dist/utils/registry.d.ts.map +1 -1
- package/dist/utils/registry.js +58 -120
- package/dist/utils/registry.js.map +1 -1
- package/dist/utils/wizard.d.ts +0 -1
- package/dist/utils/wizard.d.ts.map +1 -1
- package/dist/utils/wizard.js +73 -135
- package/dist/utils/wizard.js.map +1 -1
- package/dist/utils/write-component.d.ts +0 -9
- package/dist/utils/write-component.d.ts.map +1 -1
- package/dist/utils/write-component.js +2 -121
- package/dist/utils/write-component.js.map +1 -1
- package/package.json +8 -7
- package/dist/commands/config.d.ts +0 -2
- package/dist/commands/config.d.ts.map +0 -1
- package/dist/commands/config.js +0 -68
- package/dist/commands/config.js.map +0 -1
- package/dist/commands/doctor.d.ts +0 -2
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js +0 -348
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/list.d.ts +0 -6
- package/dist/commands/list.d.ts.map +0 -1
- package/dist/commands/list.js +0 -104
- package/dist/commands/list.js.map +0 -1
- package/dist/commands/remove.d.ts +0 -2
- package/dist/commands/remove.d.ts.map +0 -1
- package/dist/commands/remove.js +0 -87
- package/dist/commands/remove.js.map +0 -1
- package/dist/commands/search.d.ts +0 -2
- package/dist/commands/search.d.ts.map +0 -1
- package/dist/commands/search.js +0 -124
- package/dist/commands/search.js.map +0 -1
- package/dist/commands/update.d.ts +0 -6
- package/dist/commands/update.d.ts.map +0 -1
- package/dist/commands/update.js +0 -247
- package/dist/commands/update.js.map +0 -1
- package/dist/utils/lock.d.ts +0 -6
- package/dist/utils/lock.d.ts.map +0 -1
- package/dist/utils/lock.js +0 -30
- package/dist/utils/lock.js.map +0 -1
- package/dist/utils/search.d.ts +0 -21
- package/dist/utils/search.d.ts.map +0 -1
- package/dist/utils/search.js +0 -104
- package/dist/utils/search.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/utils/registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/utils/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,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CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/utils/wizard.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wizard.d.ts","sourceRoot":"","sources":["../../src/utils/wizard.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"wizard.d.ts","sourceRoot":"","sources":["../../src/utils/wizard.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;CAClC;AAgCD,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,YAAY,CAAC,CAiIrG"}
|
package/dist/utils/wizard.js
CHANGED
|
@@ -3,169 +3,107 @@ import chalk from 'chalk';
|
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { detectFramework, FRAMEWORK_OPTIONS } from './detect-framework.js';
|
|
6
|
-
import { detectCss,
|
|
6
|
+
import { detectCss, CSS_OPTIONS } from './detect-css.js';
|
|
7
7
|
import { detectTypeScript } from './detect-typescript.js';
|
|
8
|
-
import { CONFIG_FILE
|
|
8
|
+
import { CONFIG_FILE } from '../constants.js';
|
|
9
|
+
function getLabel(options, value) {
|
|
10
|
+
return options.find((o) => o.value === value)?.label ?? value;
|
|
11
|
+
}
|
|
12
|
+
function cancelAndExit(message = 'Cancelled. No changes made.') {
|
|
13
|
+
clack.outro(chalk.yellow(message));
|
|
14
|
+
process.exit(0);
|
|
15
|
+
}
|
|
16
|
+
function logDetected(label, current, detected) {
|
|
17
|
+
if (current) {
|
|
18
|
+
clack.log.info(`Current ${label}: ${chalk.cyan(current)}`);
|
|
19
|
+
}
|
|
20
|
+
else if (detected) {
|
|
21
|
+
clack.log.info(`Detected ${label}: ${chalk.cyan(detected)}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function prompt(p, message) {
|
|
25
|
+
const result = await p;
|
|
26
|
+
if (clack.isCancel(result))
|
|
27
|
+
cancelAndExit(message);
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
const DIR_VALIDATE = (value) => {
|
|
31
|
+
const trimmed = value?.trim() ?? '';
|
|
32
|
+
if (trimmed.length === 0)
|
|
33
|
+
return 'Directory path cannot be empty.';
|
|
34
|
+
if (path.isAbsolute(trimmed))
|
|
35
|
+
return 'Please use a relative path (e.g. src/components/dcntui).';
|
|
36
|
+
if (trimmed.includes('..'))
|
|
37
|
+
return 'Path must not traverse outside the project root.';
|
|
38
|
+
};
|
|
9
39
|
export async function runConfigWizard(cwd, options = {}) {
|
|
10
40
|
const { existing } = options;
|
|
11
41
|
const configPath = path.join(cwd, CONFIG_FILE);
|
|
12
|
-
let config = {};
|
|
13
|
-
if (fs.existsSync(configPath)) {
|
|
14
|
-
try {
|
|
15
|
-
config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
16
|
-
}
|
|
17
|
-
catch {
|
|
18
|
-
config = {};
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
config['version'] ?? (config['version'] = 1);
|
|
22
|
-
config['registry'] ?? (config['registry'] = REGISTRY_BASE);
|
|
23
42
|
const detectedFramework = detectFramework(cwd);
|
|
24
|
-
|
|
25
|
-
if (existing?.framework) {
|
|
26
|
-
clack.log.info(`Current framework: ${chalk.cyan(FRAMEWORK_OPTIONS.find((f) => f.value === existing.framework)?.label ?? existing.framework)}`);
|
|
27
|
-
}
|
|
28
|
-
else if (detectedFramework) {
|
|
29
|
-
clack.log.info(`Detected framework: ${chalk.cyan(FRAMEWORK_OPTIONS.find((f) => f.value === detectedFramework)?.label ?? detectedFramework)}`);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
43
|
+
logDetected('framework', existing?.framework ? getLabel(FRAMEWORK_OPTIONS, existing.framework) : undefined, detectedFramework ? getLabel(FRAMEWORK_OPTIONS, detectedFramework) : undefined);
|
|
44
|
+
if (!detectedFramework && !existing?.framework) {
|
|
32
45
|
clack.log.warn('No supported framework detected.\n\n' +
|
|
33
46
|
' Supported: Next.js, React, Svelte, SvelteKit.\n' +
|
|
34
47
|
' Select your framework manually, or choose None to exit.');
|
|
35
48
|
}
|
|
36
|
-
const framework = await clack.select({
|
|
49
|
+
const framework = await prompt(clack.select({
|
|
37
50
|
message: 'Framework:',
|
|
38
51
|
options: FRAMEWORK_OPTIONS,
|
|
39
|
-
initialValue:
|
|
52
|
+
initialValue: existing?.framework ?? detectedFramework ?? 'none',
|
|
40
53
|
maxItems: 6
|
|
41
|
-
});
|
|
42
|
-
if (clack.isCancel(framework)) {
|
|
43
|
-
clack.outro(chalk.yellow('Cancelled. No changes made.'));
|
|
44
|
-
process.exit(0);
|
|
45
|
-
}
|
|
54
|
+
}));
|
|
46
55
|
if (framework === 'none') {
|
|
47
56
|
clack.log.error(chalk.red('DCNT UI requires a supported framework to function correctly.\n\n' +
|
|
48
57
|
' Supported frameworks: Next.js (App Router & Pages Router), React, Svelte, SvelteKit.\n'));
|
|
49
58
|
clack.outro(chalk.red('Aborted. Please set up a supported framework first.'));
|
|
50
59
|
process.exit(1);
|
|
51
60
|
}
|
|
52
|
-
|
|
53
|
-
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n', 'utf-8');
|
|
54
|
-
const frameworkLabel = FRAMEWORK_OPTIONS.find((f) => f.value === framework).label;
|
|
55
|
-
clack.log.success(chalk.green(`Framework set to ${chalk.bold(frameworkLabel)}.`));
|
|
61
|
+
clack.log.success(chalk.green(`Framework set to ${chalk.bold(getLabel(FRAMEWORK_OPTIONS, framework))}.`));
|
|
56
62
|
const detectedCss = detectCss(cwd);
|
|
57
|
-
|
|
58
|
-
if (existing?.css) {
|
|
59
|
-
clack.log.info(`Current CSS strategy: ${chalk.cyan(CSS_OPTIONS.find((c) => c.value === existing.css)?.label ?? existing.css)}`);
|
|
60
|
-
}
|
|
61
|
-
else if (detectedCss) {
|
|
62
|
-
clack.log.info(`Detected CSS strategy: ${chalk.cyan(CSS_OPTIONS.find((c) => c.value === detectedCss)?.label ?? detectedCss)}`);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
63
|
+
logDetected('CSS strategy', existing?.css ? getLabel(CSS_OPTIONS, existing.css) : undefined, detectedCss ? getLabel(CSS_OPTIONS, detectedCss) : undefined);
|
|
64
|
+
if (!detectedCss && !existing?.css) {
|
|
65
65
|
clack.log.warn('Could not auto-detect a CSS strategy. Please select one manually.');
|
|
66
66
|
}
|
|
67
|
-
const css = await clack.select({
|
|
67
|
+
const css = await prompt(clack.select({
|
|
68
68
|
message: 'CSS strategy:',
|
|
69
69
|
options: CSS_OPTIONS,
|
|
70
|
-
initialValue:
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
clack.outro(chalk.yellow('Cancelled. No changes made.'));
|
|
74
|
-
process.exit(0);
|
|
75
|
-
}
|
|
76
|
-
config['css'] = css;
|
|
77
|
-
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n', 'utf-8');
|
|
78
|
-
const cssLabel = CSS_OPTIONS.find((c) => c.value === css).label;
|
|
79
|
-
clack.log.success(chalk.green(`CSS strategy set to ${chalk.bold(cssLabel)}.`));
|
|
80
|
-
const detectedStylesFile = detectBaseStylesFile(cwd, css);
|
|
81
|
-
const defaultStylesExt = css === 'scss' ? '.scss' : '.css';
|
|
82
|
-
const stylesFileDefault = existing?.stylesFile ?? detectedStylesFile ?? `src/index${defaultStylesExt}`;
|
|
83
|
-
if (existing?.stylesFile) {
|
|
84
|
-
clack.log.info(`Current base styles file: ${chalk.cyan(existing.stylesFile)}`);
|
|
85
|
-
}
|
|
86
|
-
else if (detectedStylesFile) {
|
|
87
|
-
clack.log.info(`Detected base styles file: ${chalk.cyan(detectedStylesFile)}`);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
clack.log.warn('Could not find a base styles file. Please enter the path manually.');
|
|
91
|
-
}
|
|
92
|
-
const stylesFile = await clack.text({
|
|
93
|
-
message: 'Base styles file (press Enter to use detected/default path or edit it):',
|
|
94
|
-
placeholder: stylesFileDefault,
|
|
95
|
-
defaultValue: stylesFileDefault,
|
|
96
|
-
initialValue: stylesFileDefault,
|
|
97
|
-
validate(value) {
|
|
98
|
-
const trimmed = value?.trim() ?? '';
|
|
99
|
-
if (trimmed.length === 0)
|
|
100
|
-
return 'Styles file path cannot be empty.';
|
|
101
|
-
if (path.isAbsolute(trimmed))
|
|
102
|
-
return 'Please use a relative path (e.g. src/index.css).';
|
|
103
|
-
if (trimmed.includes('..'))
|
|
104
|
-
return 'Path must not traverse outside the project root.';
|
|
105
|
-
const ext = path.extname(trimmed).toLowerCase();
|
|
106
|
-
if (!['.css', '.scss'].includes(ext))
|
|
107
|
-
return 'File must have a .css or .scss extension.';
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
if (clack.isCancel(stylesFile)) {
|
|
111
|
-
clack.outro(chalk.yellow('Cancelled. No changes made.'));
|
|
112
|
-
process.exit(0);
|
|
113
|
-
}
|
|
114
|
-
config['stylesFile'] = stylesFile.trim();
|
|
115
|
-
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n', 'utf-8');
|
|
116
|
-
clack.log.success(chalk.green(`Base styles file set to ${chalk.bold(stylesFile.trim())}.`));
|
|
70
|
+
initialValue: existing?.css ?? detectedCss
|
|
71
|
+
}), 'Cancelled. Configuration saved up to this point.');
|
|
72
|
+
clack.log.success(chalk.green(`CSS strategy set to ${chalk.bold(getLabel(CSS_OPTIONS, css))}.`));
|
|
117
73
|
const detectedTs = detectTypeScript(cwd);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
clack.log.info(`Current language: ${chalk.cyan(existing.typescript ? 'TypeScript' : 'JavaScript')}`);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
clack.log.info(`Detected language: ${chalk.cyan(detectedTs ? 'TypeScript' : 'JavaScript')}`);
|
|
124
|
-
}
|
|
125
|
-
const typescript = await clack.confirm({
|
|
126
|
-
message: 'Use TypeScript?',
|
|
127
|
-
initialValue: tsDefault
|
|
128
|
-
});
|
|
129
|
-
if (clack.isCancel(typescript)) {
|
|
130
|
-
clack.outro(chalk.yellow('Cancelled. No changes made.'));
|
|
131
|
-
process.exit(0);
|
|
132
|
-
}
|
|
133
|
-
config['typescript'] = typescript;
|
|
134
|
-
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n', 'utf-8');
|
|
74
|
+
logDetected('language', existing?.typescript !== undefined ? (existing.typescript ? 'TypeScript' : 'JavaScript') : undefined, detectedTs ? 'TypeScript' : 'JavaScript');
|
|
75
|
+
const typescript = await prompt(clack.confirm({ message: 'Use TypeScript?', initialValue: existing?.typescript ?? detectedTs }), 'Cancelled. Configuration saved up to this point.');
|
|
135
76
|
clack.log.success(chalk.green(`Language set to ${chalk.bold(typescript ? 'TypeScript' : 'JavaScript')}.`));
|
|
136
|
-
const
|
|
77
|
+
const dirDefault = existing?.componentsDir ?? (fs.existsSync(path.join(cwd, 'src')) ? 'src/components/dcntui' : 'components/dcntui');
|
|
78
|
+
let componentsDir;
|
|
137
79
|
if (existing?.componentsDir) {
|
|
138
80
|
clack.log.info(`Current components directory: ${chalk.cyan(existing.componentsDir)}`);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return 'Path must not traverse outside the project root.';
|
|
81
|
+
const useExisting = await prompt(clack.confirm({ message: 'Use this as components directory?', initialValue: true }), 'Cancelled. Configuration saved up to this point.');
|
|
82
|
+
if (useExisting) {
|
|
83
|
+
componentsDir = existing.componentsDir;
|
|
84
|
+
clack.log.success(chalk.green(`Keeping existing components directory ${chalk.bold(componentsDir.trim())}.`));
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
componentsDir = (await prompt(clack.text({
|
|
88
|
+
message: 'Components directory:',
|
|
89
|
+
placeholder: dirDefault,
|
|
90
|
+
defaultValue: dirDefault,
|
|
91
|
+
validate: DIR_VALIDATE
|
|
92
|
+
}), 'Cancelled. Configuration saved up to this point.')).trim();
|
|
93
|
+
clack.log.success(chalk.green(`Components directory set to ${chalk.bold(componentsDir)}.`));
|
|
153
94
|
}
|
|
154
|
-
});
|
|
155
|
-
if (clack.isCancel(componentsDir)) {
|
|
156
|
-
clack.outro(chalk.yellow('Cancelled. No changes made.'));
|
|
157
|
-
process.exit(0);
|
|
158
95
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
};
|
|
96
|
+
else {
|
|
97
|
+
componentsDir = (await prompt(clack.text({
|
|
98
|
+
message: 'Components directory:',
|
|
99
|
+
placeholder: dirDefault,
|
|
100
|
+
defaultValue: dirDefault,
|
|
101
|
+
validate: DIR_VALIDATE
|
|
102
|
+
}), 'Cancelled. Configuration saved up to this point.')).trim();
|
|
103
|
+
clack.log.success(chalk.green(`Components directory set to ${chalk.bold(componentsDir)}.`));
|
|
104
|
+
}
|
|
105
|
+
const result = { framework, css, typescript, componentsDir };
|
|
106
|
+
fs.writeFileSync(configPath, JSON.stringify({ version: 1, ...result }, null, 2) + '\n', 'utf-8');
|
|
107
|
+
return result;
|
|
170
108
|
}
|
|
171
109
|
//# sourceMappingURL=wizard.js.map
|
package/dist/utils/wizard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wizard.js","sourceRoot":"","sources":["../../src/utils/wizard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"wizard.js","sourceRoot":"","sources":["../../src/utils/wizard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAa9C,SAAS,QAAQ,CAAC,OAA2C,EAAE,KAAa;IAC1E,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,EAAE,KAAK,IAAI,KAAK,CAAC;AAChE,CAAC;AAED,SAAS,aAAa,CAAC,OAAO,GAAG,6BAA6B;IAC5D,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,SA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CAAC,GAAG,CAAC,CAAC,CAAC;QAC9F,CAAC;IACH,CAAC;SAAM,CAAC;QACN,aAAa,GAAG,CACd,MAAM,MAAM,CACV,KAAK,CAAC,IAAI,CAAC;YACT,OAAO,EAAE,uBAAuB;YAChC,WAAW,EAAE,UAAU;YACvB,YAAY,EAAE,UAAU;YACxB,QAAQ,EAAE,YAAY;SACvB,CAAC,EACF,kDAAkD,CACnD,CACF,CAAC,IAAI,EAAE,CAAC;QACT,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,+BAA+B,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9F,CAAC;IAED,MAAM,MAAM,GAAiB,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;IAC3E,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;IAEjG,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
import type { ComponentMetadata } from './registry.js';
|
|
2
2
|
import type { DCNTUIConfig } from './config.js';
|
|
3
3
|
export declare function writeComponentFiles(cwd: string, config: DCNTUIConfig, metadata: ComponentMetadata): string[];
|
|
4
|
-
export declare function hashContent(content: string): string;
|
|
5
|
-
export interface FileDiff {
|
|
6
|
-
filePath: string;
|
|
7
|
-
locallyModified: boolean;
|
|
8
|
-
diffLines: string[];
|
|
9
|
-
}
|
|
10
|
-
export declare function diffComponentFiles(cwd: string, config: DCNTUIConfig, metadata: ComponentMetadata): FileDiff[];
|
|
11
|
-
export declare function patchStylesFile(cwd: string, config: DCNTUIConfig, metadata: ComponentMetadata): boolean;
|
|
12
|
-
export declare function revertStylesPatch(cwd: string, config: DCNTUIConfig): boolean;
|
|
13
4
|
//# sourceMappingURL=write-component.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-component.d.ts","sourceRoot":"","sources":["../../src/utils/write-component.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"write-component.d.ts","sourceRoot":"","sources":["../../src/utils/write-component.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,GAAG,MAAM,EAAE,CAW5G"}
|
|
@@ -1,132 +1,13 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { createHash } from 'node:crypto';
|
|
4
3
|
export function writeComponentFiles(cwd, config, metadata) {
|
|
5
4
|
const componentDir = path.join(cwd, config.componentsDir, metadata.name);
|
|
6
5
|
fs.mkdirSync(componentDir, { recursive: true });
|
|
7
|
-
|
|
8
|
-
for (const file of metadata.files) {
|
|
6
|
+
return metadata.files.map((file) => {
|
|
9
7
|
const dest = path.join(componentDir, file.path);
|
|
10
8
|
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
11
9
|
fs.writeFileSync(dest, file.content, 'utf-8');
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
const dcntuiDir = path.join(cwd, '.dcntui');
|
|
15
|
-
fs.mkdirSync(dcntuiDir, { recursive: true });
|
|
16
|
-
const fileHashes = {};
|
|
17
|
-
for (const file of metadata.files) {
|
|
18
|
-
fileHashes[file.path] = hashContent(file.content);
|
|
19
|
-
}
|
|
20
|
-
fs.writeFileSync(path.join(dcntuiDir, `${metadata.name}.json`), JSON.stringify({
|
|
21
|
-
name: metadata.name,
|
|
22
|
-
version: metadata.version,
|
|
23
|
-
dependencies: metadata.dependencies,
|
|
24
|
-
fileHashes
|
|
25
|
-
}, null, 2) + '\n', 'utf-8');
|
|
26
|
-
return written;
|
|
27
|
-
}
|
|
28
|
-
export function hashContent(content) {
|
|
29
|
-
return createHash('sha256').update(content, 'utf-8').digest('hex');
|
|
30
|
-
}
|
|
31
|
-
export function diffComponentFiles(cwd, config, metadata) {
|
|
32
|
-
const componentDir = path.join(cwd, config.componentsDir, metadata.name);
|
|
33
|
-
const metaPath = path.join(cwd, '.dcntui', `${metadata.name}.json`);
|
|
34
|
-
let storedHashes = {};
|
|
35
|
-
if (fs.existsSync(metaPath)) {
|
|
36
|
-
try {
|
|
37
|
-
const meta = JSON.parse(fs.readFileSync(metaPath, 'utf-8'));
|
|
38
|
-
storedHashes = meta.fileHashes ?? {};
|
|
39
|
-
}
|
|
40
|
-
catch { }
|
|
41
|
-
}
|
|
42
|
-
return metadata.files.map((file) => {
|
|
43
|
-
const diskPath = path.join(componentDir, file.path);
|
|
44
|
-
const diskExists = fs.existsSync(diskPath);
|
|
45
|
-
if (!diskExists) {
|
|
46
|
-
return { filePath: file.path, locallyModified: false, diffLines: [] };
|
|
47
|
-
}
|
|
48
|
-
const diskContent = fs.readFileSync(diskPath, 'utf-8');
|
|
49
|
-
const diskHash = hashContent(diskContent);
|
|
50
|
-
const remoteHash = hashContent(file.content);
|
|
51
|
-
const installedHash = storedHashes[file.path];
|
|
52
|
-
const locallyModified = installedHash !== undefined && diskHash !== installedHash && diskHash !== remoteHash;
|
|
53
|
-
const diffLines = locallyModified ? buildDiffLines(file.path, diskContent, file.content) : [];
|
|
54
|
-
return { filePath: file.path, locallyModified, diffLines };
|
|
10
|
+
return path.relative(cwd, dest);
|
|
55
11
|
});
|
|
56
12
|
}
|
|
57
|
-
function buildDiffLines(filePath, oldText, newText) {
|
|
58
|
-
const oldLines = oldText.split('\n');
|
|
59
|
-
const newLines = newText.split('\n');
|
|
60
|
-
const output = [];
|
|
61
|
-
const maxLen = Math.max(oldLines.length, newLines.length);
|
|
62
|
-
output.push(`--- ${filePath} (local)`);
|
|
63
|
-
output.push(`+++ ${filePath} (registry)`);
|
|
64
|
-
let changed = false;
|
|
65
|
-
for (let i = 0; i < maxLen; i++) {
|
|
66
|
-
const oldLine = oldLines[i];
|
|
67
|
-
const newLine = newLines[i];
|
|
68
|
-
if (oldLine === undefined) {
|
|
69
|
-
output.push(`+ ${newLine}`);
|
|
70
|
-
changed = true;
|
|
71
|
-
}
|
|
72
|
-
else if (newLine === undefined) {
|
|
73
|
-
output.push(`- ${oldLine}`);
|
|
74
|
-
changed = true;
|
|
75
|
-
}
|
|
76
|
-
else if (oldLine !== newLine) {
|
|
77
|
-
output.push(`- ${oldLine}`);
|
|
78
|
-
output.push(`+ ${newLine}`);
|
|
79
|
-
changed = true;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
output.push(` ${oldLine}`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return changed ? output : [];
|
|
86
|
-
}
|
|
87
|
-
const DCNTUI_START = '/* dcntui:start */';
|
|
88
|
-
const DCNTUI_END = '/* dcntui:end */';
|
|
89
|
-
export function patchStylesFile(cwd, config, metadata) {
|
|
90
|
-
const stylesPath = path.join(cwd, config.stylesFile);
|
|
91
|
-
const cssBlock = buildCssBlock(config, metadata);
|
|
92
|
-
if (!cssBlock)
|
|
93
|
-
return false;
|
|
94
|
-
if (!fs.existsSync(stylesPath)) {
|
|
95
|
-
fs.mkdirSync(path.dirname(stylesPath), { recursive: true });
|
|
96
|
-
fs.writeFileSync(stylesPath, '', 'utf-8');
|
|
97
|
-
}
|
|
98
|
-
let content = fs.readFileSync(stylesPath, 'utf-8');
|
|
99
|
-
const markedBlock = `${DCNTUI_START}\n${cssBlock}\n${DCNTUI_END}`;
|
|
100
|
-
if (content.includes(DCNTUI_START) && content.includes(DCNTUI_END)) {
|
|
101
|
-
content = content.replace(new RegExp(`\\/\\* dcntui:start \\*\\/[\\s\\S]*?\\/\\* dcntui:end \\*\\/`, 'g'), markedBlock);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
content = content.trimEnd() + '\n\n' + markedBlock + '\n';
|
|
105
|
-
}
|
|
106
|
-
fs.writeFileSync(stylesPath, content, 'utf-8');
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
export function revertStylesPatch(cwd, config) {
|
|
110
|
-
const stylesPath = path.join(cwd, config.stylesFile);
|
|
111
|
-
if (!fs.existsSync(stylesPath))
|
|
112
|
-
return false;
|
|
113
|
-
let content = fs.readFileSync(stylesPath, 'utf-8');
|
|
114
|
-
if (!content.includes(DCNTUI_START))
|
|
115
|
-
return false;
|
|
116
|
-
content = content.replace(/\n*\/\* dcntui:start \*\/[\s\S]*?\/\* dcntui:end \*\/\n*/g, '\n');
|
|
117
|
-
fs.writeFileSync(stylesPath, content.trimEnd() + '\n', 'utf-8');
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
function buildCssBlock(config, metadata) {
|
|
121
|
-
const { tailwind } = metadata;
|
|
122
|
-
switch (config.css) {
|
|
123
|
-
case 'tailwind-v4':
|
|
124
|
-
return tailwind.v4 ?? null;
|
|
125
|
-
case 'tailwind-v3':
|
|
126
|
-
return tailwind.v3 ?? null;
|
|
127
|
-
case 'scss':
|
|
128
|
-
case 'css':
|
|
129
|
-
return tailwind.v4 ?? tailwind.v3 ?? null;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
13
|
//# sourceMappingURL=write-component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-component.js","sourceRoot":"","sources":["../../src/utils/write-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"write-component.js","sourceRoot":"","sources":["../../src/utils/write-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAK7B,MAAM,UAAU,mBAAmB,CAAC,GAAW,EAAE,MAAoB,EAAE,QAA2B;IAChG,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEzE,EAAE,CAAC,SAAS,CAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAEhD,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dcntui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "CLI for initializing DCNT UI and adding components to projects",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -17,18 +17,19 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@clack/prompts": "^1.4.0",
|
|
20
|
-
"chalk": "^5.
|
|
21
|
-
"commander": "^
|
|
22
|
-
"
|
|
20
|
+
"chalk": "^5.6.2",
|
|
21
|
+
"commander": "^14.0.3",
|
|
22
|
+
"figlet": "^1.11.0",
|
|
23
|
+
"gradient-string": "^3.0.0"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
|
-
"@types/node": "^
|
|
26
|
+
"@types/node": "^25.7.0",
|
|
26
27
|
"eslint": "^10.3.0",
|
|
27
28
|
"eslint-config-prettier": "^10.1.8",
|
|
28
29
|
"prettier": "^3.8.3",
|
|
29
30
|
"tsx": "^4.21.0",
|
|
30
|
-
"typescript": "^
|
|
31
|
-
"typescript-eslint": "^8.59.
|
|
31
|
+
"typescript": "^6.0.3",
|
|
32
|
+
"typescript-eslint": "^8.59.3"
|
|
32
33
|
},
|
|
33
34
|
"engines": {
|
|
34
35
|
"node": ">=18.0.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAOA,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC,CAkGnD"}
|