@vadimcomanescu/nadicode-design-system 4.0.2 → 4.0.3
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.
|
@@ -15,7 +15,6 @@ export const nadicodeRules = {
|
|
|
15
15
|
"nadicode/no-admin-manual-chart-bars": "error",
|
|
16
16
|
"nadicode/no-app-primitive-composition": "error",
|
|
17
17
|
"nadicode/no-barrel-imports": "error",
|
|
18
|
-
"nadicode/no-deprecated-ds-import": "warn",
|
|
19
18
|
"nadicode/no-derived-state-via-useeffect": "error",
|
|
20
19
|
"nadicode/no-direct-lucide-import": "error",
|
|
21
20
|
"nadicode/no-external-ui-library": "error",
|
|
@@ -3,7 +3,6 @@ import noAdminManualChartBars from "./rules/no-admin-manual-chart-bars.js";
|
|
|
3
3
|
import noAppPrimitiveComposition from "./rules/no-app-primitive-composition.js";
|
|
4
4
|
import noArbitraryChartColor from "./rules/no-arbitrary-chart-color.js";
|
|
5
5
|
import noBarrelImports from "./rules/no-barrel-imports.js";
|
|
6
|
-
import noDeprecatedDsImport from "./rules/no-deprecated-ds-import.js";
|
|
7
6
|
import noDeprecatedSegmentConfig from "./rules/no-deprecated-segment-config.js";
|
|
8
7
|
import noDerivedStateViaUseeffect from "./rules/no-derived-state-via-useeffect.js";
|
|
9
8
|
import noDirectLucideImport from "./rules/no-direct-lucide-import.js";
|
|
@@ -81,7 +80,6 @@ export const nadicodePlugin = {
|
|
|
81
80
|
"no-app-primitive-composition": noAppPrimitiveComposition,
|
|
82
81
|
"no-arbitrary-chart-color": noArbitraryChartColor,
|
|
83
82
|
"no-barrel-imports": noBarrelImports,
|
|
84
|
-
"no-deprecated-ds-import": noDeprecatedDsImport,
|
|
85
83
|
"no-deprecated-segment-config": noDeprecatedSegmentConfig,
|
|
86
84
|
"no-derived-state-via-useeffect": noDerivedStateViaUseeffect,
|
|
87
85
|
"no-direct-lucide-import": noDirectLucideImport,
|
package/package.json
CHANGED
package/scripts/ds-update.mjs
CHANGED
|
@@ -10,6 +10,10 @@ function run(command) {
|
|
|
10
10
|
execSync(command, { cwd: process.cwd(), stdio: "inherit" });
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
function runCapture(command) {
|
|
14
|
+
return execSync(command, { cwd: process.cwd(), encoding: "utf8" }).trim();
|
|
15
|
+
}
|
|
16
|
+
|
|
13
17
|
function readPackageJson() {
|
|
14
18
|
const packageJsonPath = join(process.cwd(), "package.json");
|
|
15
19
|
if (!existsSync(packageJsonPath)) {
|
|
@@ -23,28 +27,62 @@ function readSeedDependency() {
|
|
|
23
27
|
const packageJson = readPackageJson();
|
|
24
28
|
const dependency = packageJson.dependencies?.[PACKAGE_NAME];
|
|
25
29
|
if (dependency) {
|
|
26
|
-
return {
|
|
30
|
+
return { currentSpec: dependency, isDevDependency: false };
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
const devDependency = packageJson.devDependencies?.[PACKAGE_NAME];
|
|
30
34
|
if (devDependency) {
|
|
31
|
-
return {
|
|
35
|
+
return { currentSpec: devDependency, isDevDependency: true };
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
throw new Error("package.json must declare @vadimcomanescu/nadicode-design-system before ds:update can run.");
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
function fetchLatestVersion() {
|
|
42
|
+
try {
|
|
43
|
+
return runCapture(`npm view ${PACKAGE_NAME} version`);
|
|
44
|
+
} catch {
|
|
45
|
+
throw new Error(`Failed to fetch latest version of ${PACKAGE_NAME} from the registry.`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function detectPackageManager() {
|
|
50
|
+
if (existsSync(join(process.cwd(), "pnpm-lock.yaml"))) return "pnpm";
|
|
51
|
+
if (existsSync(join(process.cwd(), "yarn.lock"))) return "yarn";
|
|
52
|
+
if (existsSync(join(process.cwd(), "bun.lock"))) return "bun";
|
|
53
|
+
return "npm";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function buildInstallCommand(pm, target, isDevDependency) {
|
|
57
|
+
const devFlag = {
|
|
58
|
+
pnpm: isDevDependency ? "-D " : "",
|
|
59
|
+
yarn: isDevDependency ? "--dev " : "",
|
|
60
|
+
bun: isDevDependency ? "-d " : "",
|
|
61
|
+
npm: isDevDependency ? "-D " : "",
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const command = {
|
|
65
|
+
pnpm: "pnpm add --save-exact",
|
|
66
|
+
yarn: "yarn add --exact",
|
|
67
|
+
bun: "bun add --exact",
|
|
68
|
+
npm: "npm install --save-exact",
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return `${command[pm]} ${devFlag[pm]}${JSON.stringify(target)}`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const { currentSpec, isDevDependency } = readSeedDependency();
|
|
75
|
+
const latestVersion = fetchLatestVersion();
|
|
76
|
+
const installTarget = `${PACKAGE_NAME}@${latestVersion}`;
|
|
77
|
+
const pm = detectPackageManager();
|
|
78
|
+
|
|
79
|
+
if (currentSpec === latestVersion) {
|
|
80
|
+
console.log(`Already on latest version (${latestVersion}). Syncing skill docs.`);
|
|
81
|
+
} else {
|
|
82
|
+
console.log(`Updating ${PACKAGE_NAME}: ${currentSpec} -> ${latestVersion}`);
|
|
83
|
+
run(buildInstallCommand(pm, installTarget, isDevDependency));
|
|
84
|
+
}
|
|
46
85
|
|
|
47
|
-
run(
|
|
48
|
-
run(`node ${JSON.stringify(join(process.cwd(), "node_modules", "@vadimcomanescu/nadicode-design-system", "scripts", "sync-seed-skill.mjs"))} ${JSON.stringify(process.cwd())}`);
|
|
86
|
+
run(`node ${JSON.stringify(join(process.cwd(), "node_modules", PACKAGE_NAME, "scripts", "sync-seed-skill.mjs"))} ${JSON.stringify(process.cwd())}`);
|
|
49
87
|
|
|
50
|
-
console.log(
|
|
88
|
+
console.log(`Done (${latestVersion}). Run npm run ds:check to verify.`);
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { resolve, dirname } from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
|
|
5
|
-
const RULES_DIR = dirname(fileURLToPath(import.meta.url));
|
|
6
|
-
const REGISTRY_PATH = resolve(RULES_DIR, "../../../contracts/public-surface-registry.json");
|
|
7
|
-
const DS_PACKAGE = "@vadimcomanescu/nadicode-design-system";
|
|
8
|
-
|
|
9
|
-
let deprecatedSubpaths = null;
|
|
10
|
-
|
|
11
|
-
function loadDeprecatedSubpaths() {
|
|
12
|
-
if (deprecatedSubpaths) {
|
|
13
|
-
return deprecatedSubpaths;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
deprecatedSubpaths = new Map();
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
const registry = JSON.parse(readFileSync(REGISTRY_PATH, "utf8"));
|
|
20
|
-
for (const entry of registry.entries ?? []) {
|
|
21
|
-
if (entry.stability === "deprecated" && entry.deprecation) {
|
|
22
|
-
deprecatedSubpaths.set(entry.subpath, {
|
|
23
|
-
replacement: entry.deprecation.replacement,
|
|
24
|
-
removalVersion: entry.deprecation.removalVersion,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
} catch {
|
|
29
|
-
// Registry unavailable (e.g. consumer repo without local contracts).
|
|
30
|
-
// Rule becomes a no-op.
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return deprecatedSubpaths;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const rule = {
|
|
37
|
-
meta: {
|
|
38
|
-
type: "suggestion",
|
|
39
|
-
docs: {
|
|
40
|
-
description:
|
|
41
|
-
"Warn when importing a deprecated export from @vadimcomanescu/nadicode-design-system.",
|
|
42
|
-
},
|
|
43
|
-
schema: [],
|
|
44
|
-
},
|
|
45
|
-
create(context) {
|
|
46
|
-
return {
|
|
47
|
-
ImportDeclaration(node) {
|
|
48
|
-
const source = node.source.value;
|
|
49
|
-
if (typeof source !== "string" || !source.startsWith(DS_PACKAGE)) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const subpath = "./" + source.slice(DS_PACKAGE.length + 1);
|
|
54
|
-
if (subpath === "./") {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const deprecated = loadDeprecatedSubpaths();
|
|
59
|
-
const info = deprecated.get(subpath);
|
|
60
|
-
if (!info) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const parts = [
|
|
65
|
-
`"${source}" is deprecated and will be removed in v${info.removalVersion}.`,
|
|
66
|
-
];
|
|
67
|
-
if (info.replacement) {
|
|
68
|
-
parts.push(`Use "${DS_PACKAGE}/${info.replacement.slice(2)}" instead.`);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
context.report({ node, message: parts.join(" ") });
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export default rule;
|