zard-cli 1.1.3 → 1.3.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/commands/add/component-selector.d.ts +4 -0
- package/commands/add/component-selector.d.ts.map +1 -1
- package/commands/add/component-selector.js +13 -1
- package/commands/add/component-selector.js.map +1 -1
- package/commands/add/install-aliases.d.ts +9 -0
- package/commands/add/install-aliases.d.ts.map +1 -0
- package/commands/add/install-aliases.js +34 -0
- package/commands/add/install-aliases.js.map +1 -0
- package/package.json +1 -1
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Returns an empty list when nothing was given: the wizard picks in that case
|
|
5
5
|
* (or, with no interactive terminal, the command fails asking for the names).
|
|
6
|
+
*
|
|
7
|
+
* A name that is really another item's page — `toast`, which is `sonner` — is
|
|
8
|
+
* replaced by the item and the replacement is said out loud, so a script that
|
|
9
|
+
* relies on the old name sees what was installed.
|
|
6
10
|
*/
|
|
7
11
|
export declare function selectComponents(components: string[], allFlag: boolean): Promise<string[]>;
|
|
8
12
|
//# sourceMappingURL=component-selector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-selector.d.ts","sourceRoot":"","sources":["../../../src/commands/add/component-selector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"component-selector.d.ts","sourceRoot":"","sources":["../../../src/commands/add/component-selector.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAUhG"}
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
import { getAllComponentNames } from './dependency-resolver.js';
|
|
2
|
+
import { resolveInstallAliases } from './install-aliases.js';
|
|
3
|
+
import { logger } from '../../utils/logger.js';
|
|
2
4
|
/**
|
|
3
5
|
* Works out which components the command should install, from its arguments.
|
|
4
6
|
*
|
|
5
7
|
* Returns an empty list when nothing was given: the wizard picks in that case
|
|
6
8
|
* (or, with no interactive terminal, the command fails asking for the names).
|
|
9
|
+
*
|
|
10
|
+
* A name that is really another item's page — `toast`, which is `sonner` — is
|
|
11
|
+
* replaced by the item and the replacement is said out loud, so a script that
|
|
12
|
+
* relies on the old name sees what was installed.
|
|
7
13
|
*/
|
|
8
14
|
export async function selectComponents(components, allFlag) {
|
|
9
15
|
if (allFlag)
|
|
10
16
|
return getAllComponentNames();
|
|
11
|
-
|
|
17
|
+
const requested = components ?? [];
|
|
18
|
+
if (!requested.length)
|
|
19
|
+
return requested;
|
|
20
|
+
const { names, replaced } = resolveInstallAliases(requested, new Set(await getAllComponentNames()));
|
|
21
|
+
for (const [given, installed] of replaced)
|
|
22
|
+
logger.info(`${given} → ${installed}`);
|
|
23
|
+
return names;
|
|
12
24
|
}
|
|
13
25
|
//# sourceMappingURL=component-selector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-selector.js","sourceRoot":"","sources":["../../../src/commands/add/component-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"component-selector.js","sourceRoot":"","sources":["../../../src/commands/add/component-selector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,UAAoB,EAAE,OAAgB;IAC3E,IAAI,OAAO;QAAE,OAAO,oBAAoB,EAAE,CAAC;IAE3C,MAAM,SAAS,GAAG,UAAU,IAAI,EAAE,CAAC;IACnC,IAAI,CAAC,SAAS,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAExC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,qBAAqB,CAAC,SAAS,EAAE,IAAI,GAAG,CAAC,MAAM,oBAAoB,EAAE,CAAC,CAAC,CAAC;IACpG,KAAK,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,QAAQ;QAAE,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,MAAM,SAAS,EAAE,CAAC,CAAC;IAElF,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const INSTALL_ALIASES: Readonly<Record<string, string>>;
|
|
2
|
+
export interface ResolvedAliases {
|
|
3
|
+
/** The names to install, aliases replaced and duplicates removed, in the order given. */
|
|
4
|
+
names: string[];
|
|
5
|
+
/** Each alias that was replaced, as `[given, installed]`. */
|
|
6
|
+
replaced: Array<[string, string]>;
|
|
7
|
+
}
|
|
8
|
+
export declare function resolveInstallAliases(names: readonly string[], registryNames: ReadonlySet<string>): ResolvedAliases;
|
|
9
|
+
//# sourceMappingURL=install-aliases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-aliases.d.ts","sourceRoot":"","sources":["../../../src/commands/add/install-aliases.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAW5D,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,yFAAyF;IACzF,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,6DAA6D;IAC7D,QAAQ,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACnC;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,eAAe,CAanH"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Names people bring from the docs or from other libraries that point at a
|
|
3
|
+
* registry item under a different name.
|
|
4
|
+
*
|
|
5
|
+
* Only unambiguous one-to-one aliases belong here: each one is an install name.
|
|
6
|
+
* An alias can never shadow a real item — `resolveInstallAliases` is told which
|
|
7
|
+
* names the registry really has and leaves those alone.
|
|
8
|
+
*/
|
|
9
|
+
export const INSTALL_ALIASES = {
|
|
10
|
+
/**
|
|
11
|
+
* Toast has a page in the components list but no files of its own: shadcn/ui
|
|
12
|
+
* deprecated it in favour of Sonner, so `add toast` installs `sonner`.
|
|
13
|
+
*/
|
|
14
|
+
toast: 'sonner',
|
|
15
|
+
/**
|
|
16
|
+
* Typography is the components-list entry for Typeset, as in shadcn/ui: it opens
|
|
17
|
+
* the Typeset docs, so `add typography` installs the `typeset` stylesheet.
|
|
18
|
+
*/
|
|
19
|
+
typography: 'typeset',
|
|
20
|
+
};
|
|
21
|
+
export function resolveInstallAliases(names, registryNames) {
|
|
22
|
+
const resolved = [];
|
|
23
|
+
const replaced = [];
|
|
24
|
+
for (const name of names) {
|
|
25
|
+
const target = !registryNames.has(name) ? INSTALL_ALIASES[name] : undefined;
|
|
26
|
+
if (target)
|
|
27
|
+
replaced.push([name, target]);
|
|
28
|
+
const final = target ?? name;
|
|
29
|
+
if (!resolved.includes(final))
|
|
30
|
+
resolved.push(final);
|
|
31
|
+
}
|
|
32
|
+
return { names: resolved, replaced };
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=install-aliases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-aliases.js","sourceRoot":"","sources":["../../../src/commands/add/install-aliases.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAqC;IAC/D;;;OAGG;IACH,KAAK,EAAE,QAAQ;IACf;;;OAGG;IACH,UAAU,EAAE,SAAS;CACtB,CAAC;AASF,MAAM,UAAU,qBAAqB,CAAC,KAAwB,EAAE,aAAkC;IAChG,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,QAAQ,GAA4B,EAAE,CAAC;IAE7C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5E,IAAI,MAAM;YAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QAE1C,MAAM,KAAK,GAAG,MAAM,IAAI,IAAI,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;AACvC,CAAC"}
|