@archetypeai/ds-cli 0.3.7

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.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +123 -0
  3. package/bin.js +77 -0
  4. package/commands/add.js +42 -0
  5. package/commands/create.js +238 -0
  6. package/commands/init.js +199 -0
  7. package/files/AGENTS.md +63 -0
  8. package/files/CLAUDE.md +63 -0
  9. package/files/LICENSE +21 -0
  10. package/files/rules/accessibility.md +219 -0
  11. package/files/rules/charts.md +352 -0
  12. package/files/rules/components.md +267 -0
  13. package/files/rules/design-principles.md +56 -0
  14. package/files/rules/linting.md +31 -0
  15. package/files/rules/state.md +405 -0
  16. package/files/rules/styling.md +245 -0
  17. package/files/skills/apply-ds/SKILL.md +117 -0
  18. package/files/skills/apply-ds/scripts/setup.sh +271 -0
  19. package/files/skills/build-pattern/SKILL.md +202 -0
  20. package/files/skills/create-dashboard/SKILL.md +189 -0
  21. package/files/skills/deploy-worker/SKILL.md +231 -0
  22. package/files/skills/deploy-worker/references/wrangler-commands.md +327 -0
  23. package/files/skills/fix-accessibility/SKILL.md +184 -0
  24. package/files/skills/fix-metadata/SKILL.md +118 -0
  25. package/files/skills/fix-metadata/assets/favicon.ico +0 -0
  26. package/files/skills/setup-chart/SKILL.md +225 -0
  27. package/files/skills/setup-chart/data/embedding.csv +42 -0
  28. package/files/skills/setup-chart/data/timeseries.csv +173 -0
  29. package/files/skills/setup-chart/references/scatter-chart.md +229 -0
  30. package/files/skills/setup-chart/references/sensor-chart.md +156 -0
  31. package/lib/add-ds-config-codeagent.js +154 -0
  32. package/lib/add-ds-ui-svelte.js +93 -0
  33. package/lib/scaffold-ds-svelte-project.js +272 -0
  34. package/lib/use-package-manager.js +65 -0
  35. package/lib/use-shadcn-svelte-registry.js +26 -0
  36. package/lib/validate-url.js +31 -0
  37. package/package.json +34 -0
@@ -0,0 +1,65 @@
1
+ import { execSync } from 'child_process';
2
+ import { existsSync } from 'fs';
3
+ import { join } from 'path';
4
+
5
+ // package managers
6
+ const managers = {
7
+ npm: {
8
+ name: 'npm',
9
+ install: 'npm install',
10
+ dlx: 'npx',
11
+ svInstallFlag: '--install npm',
12
+ lockfile: 'package-lock.json'
13
+ },
14
+ pnpm: {
15
+ name: 'pnpm',
16
+ install: 'pnpm add',
17
+ dlx: 'pnpm dlx',
18
+ svInstallFlag: '--install pnpm',
19
+ lockfile: 'pnpm-lock.yaml'
20
+ },
21
+ bun: {
22
+ name: 'bun',
23
+ install: 'bun add',
24
+ dlx: 'bunx',
25
+ svInstallFlag: '--install bun',
26
+ lockfile: 'bun.lockb'
27
+ },
28
+ yarn: {
29
+ name: 'yarn',
30
+ install: 'yarn add',
31
+ dlx: 'yarn dlx',
32
+ svInstallFlag: '--install yarn',
33
+ lockfile: 'yarn.lock'
34
+ }
35
+ };
36
+
37
+ // get package manager
38
+ export function getPm(name) {
39
+ const pm = managers[name];
40
+ if (!pm) throw new Error(`Unknown package manager: ${name}`);
41
+ return pm;
42
+ }
43
+
44
+ // check if package manager is installed
45
+ export function isPmInstalled(name) {
46
+ try {
47
+ execSync(`${name} --version`, { stdio: 'pipe' });
48
+ return true;
49
+ } catch {
50
+ return false;
51
+ }
52
+ }
53
+
54
+ // detect package manager from project path
55
+ export function detectPm(projectPath) {
56
+ for (const [name, pm] of Object.entries(managers)) {
57
+ if (existsSync(join(projectPath, pm.lockfile))) {
58
+ return name;
59
+ }
60
+ }
61
+ return null;
62
+ }
63
+
64
+ // package manager names
65
+ export const pmNames = Object.keys(managers);
@@ -0,0 +1,26 @@
1
+ import { validateRegistryUrl } from './validate-url.js';
2
+
3
+ // override with REGISTRY_URL env var for testing or private registries
4
+ const REGISTRY_URL = process.env.REGISTRY_URL || 'https://design-system.archetypeai.workers.dev';
5
+ const ALL_COMPONENTS_URL = `${REGISTRY_URL}/r/all.json`;
6
+
7
+ // fetch components via shadcn-svelte registry from all.json endpoint
8
+ export async function fetchComponents() {
9
+ const response = await fetch(ALL_COMPONENTS_URL, {
10
+ signal: AbortSignal.timeout(15_000)
11
+ });
12
+ if (!response.ok) {
13
+ throw new Error(`Failed to fetch component registry (${response.status})`);
14
+ }
15
+
16
+ const urls = await response.json();
17
+ if (!Array.isArray(urls) || urls.length === 0) {
18
+ throw new Error('No components found in registry');
19
+ }
20
+
21
+ return urls.map((url) => {
22
+ validateRegistryUrl(url);
23
+ const match = url.match(/\/r\/([^/]+)\.json$/);
24
+ return { name: match ? match[1] : url, url };
25
+ });
26
+ }
@@ -0,0 +1,31 @@
1
+ // validate a registry URL before using it in shell commands
2
+ const VALID_PATH_PATTERN = /^\/r\/[a-z0-9-]+\.json$/;
3
+
4
+ export function validateRegistryUrl(url) {
5
+ if (typeof url !== 'string') {
6
+ throw new Error(`Invalid registry URL: expected string, got ${typeof url}`);
7
+ }
8
+
9
+ let parsed;
10
+ try {
11
+ parsed = new URL(url);
12
+ } catch {
13
+ throw new Error(`Invalid registry URL: "${url}" is not a valid URL`);
14
+ }
15
+
16
+ if (parsed.protocol !== 'https:') {
17
+ throw new Error(`Invalid registry URL: "${url}" must use https protocol`);
18
+ }
19
+
20
+ if (!VALID_PATH_PATTERN.test(parsed.pathname)) {
21
+ throw new Error(
22
+ `Invalid registry URL: "${url}" does not match expected /r/<name>.json pattern`
23
+ );
24
+ }
25
+
26
+ if (parsed.search || parsed.hash) {
27
+ throw new Error(`Invalid registry URL: "${url}" must not contain query params or fragments`);
28
+ }
29
+
30
+ return url;
31
+ }
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@archetypeai/ds-cli",
3
+ "version": "0.3.7",
4
+ "description": "Archetype AI Design System CLI",
5
+ "type": "module",
6
+ "bin": {
7
+ "ds": "./bin.js"
8
+ },
9
+ "files": [
10
+ "bin.js",
11
+ "commands",
12
+ "lib",
13
+ "files",
14
+ "LICENSE"
15
+ ],
16
+ "engines": {
17
+ "node": ">=20.0.0"
18
+ },
19
+ "dependencies": {
20
+ "@clack/prompts": "^0.10.0"
21
+ },
22
+ "scripts": {
23
+ "build": "rm -rf dist && mkdir -p dist/commands dist/lib dist/files && cp bin.js package.json ../LICENSE dist/ && cp commands/*.js dist/commands/ && cp lib/*.js dist/lib/ && cp -r ../ds-config-codeagent/AGENTS.md ../ds-config-codeagent/CLAUDE.md dist/files/ && cp -r ../ds-config-codeagent/skills ../ds-config-codeagent/rules dist/files/ && cp ../LICENSE dist/files/ && chmod +x dist/bin.js && cp ../docs/DS-CLI.md dist/README.md"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/archetypeai/design-system.git",
28
+ "directory": "ds-cli"
29
+ },
30
+ "publishConfig": {
31
+ "registry": "https://registry.npmjs.org"
32
+ },
33
+ "license": "MIT"
34
+ }