@omnitron-dev/prism 0.3.1 → 0.3.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.
- package/README.md +68 -2
- package/THIRD-PARTY-NOTICES.txt +26 -0
- package/dist/accessibility/index.js +2 -0
- package/dist/accessibility/index.js.map +1 -1
- package/dist/auth/index.d.ts +4 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +4 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/blocks/auth-block/guards.d.ts +3 -2
- package/dist/blocks/auth-block/guards.d.ts.map +1 -1
- package/dist/blocks/dashboard-block/dashboard-block.d.ts.map +1 -1
- package/dist/blocks/dashboard-block/types.d.ts +4 -2
- package/dist/blocks/dashboard-block/types.d.ts.map +1 -1
- package/dist/blocks/dashboard-block/use-dashboard-block.d.ts +2 -2
- package/dist/blocks/dashboard-block/use-dashboard-block.d.ts.map +1 -1
- package/dist/blocks/data-grid-block/data-grid-block.d.ts.map +1 -1
- package/dist/blocks/data-grid-block/types.d.ts +3 -0
- package/dist/blocks/data-grid-block/types.d.ts.map +1 -1
- package/dist/blocks/index.js +80 -255
- package/dist/blocks/index.js.map +1 -1
- package/dist/chunk-2AB7VGPW.js +447 -0
- package/dist/chunk-2AB7VGPW.js.map +1 -0
- package/dist/{chunk-LOY2NPCO.js → chunk-2E67PQ4T.js} +3 -3
- package/dist/{chunk-LOY2NPCO.js.map → chunk-2E67PQ4T.js.map} +1 -1
- package/dist/chunk-2KG2NI73.js +84 -0
- package/dist/chunk-2KG2NI73.js.map +1 -0
- package/dist/chunk-2UYRW6X3.js +44 -0
- package/dist/chunk-2UYRW6X3.js.map +1 -0
- package/dist/chunk-36C5H56C.js +208 -0
- package/dist/chunk-36C5H56C.js.map +1 -0
- package/dist/chunk-36FOXX25.js +73 -0
- package/dist/chunk-36FOXX25.js.map +1 -0
- package/dist/{chunk-52PQL67Q.js → chunk-3VSM7NZG.js} +18 -15
- package/dist/chunk-3VSM7NZG.js.map +1 -0
- package/dist/{chunk-GUGTDURV.js → chunk-4B2LTPK2.js} +2 -2
- package/dist/{chunk-GUGTDURV.js.map → chunk-4B2LTPK2.js.map} +1 -1
- package/dist/chunk-4HUGZJKU.js +108 -0
- package/dist/chunk-4HUGZJKU.js.map +1 -0
- package/dist/{chunk-PXXPLHIY.js → chunk-4Q5L7LDG.js} +3 -3
- package/dist/{chunk-PXXPLHIY.js.map → chunk-4Q5L7LDG.js.map} +1 -1
- package/dist/{chunk-BRDWQVRT.js → chunk-4R7EZ7GQ.js} +3 -2
- package/dist/chunk-4R7EZ7GQ.js.map +1 -0
- package/dist/chunk-6IANOSMD.js +185 -0
- package/dist/chunk-6IANOSMD.js.map +1 -0
- package/dist/{chunk-YHE7HXSG.js → chunk-7ATBURW2.js} +3 -3
- package/dist/{chunk-YHE7HXSG.js.map → chunk-7ATBURW2.js.map} +1 -1
- package/dist/{chunk-7G5D5PTC.js → chunk-AATAOOSF.js} +4 -4
- package/dist/{chunk-7G5D5PTC.js.map → chunk-AATAOOSF.js.map} +1 -1
- package/dist/chunk-AKLRKCYH.js +128 -0
- package/dist/chunk-AKLRKCYH.js.map +1 -0
- package/dist/chunk-CT46KJOR.js +133 -0
- package/dist/chunk-CT46KJOR.js.map +1 -0
- package/dist/{chunk-LSPFFEJT.js → chunk-D4GFAJAZ.js} +298 -3900
- package/dist/chunk-D4GFAJAZ.js.map +1 -0
- package/dist/{chunk-BJE2AKD4.js → chunk-D5J3KW6Q.js} +3 -2
- package/dist/chunk-D5J3KW6Q.js.map +1 -0
- package/dist/chunk-DEPJRTVT.js +3 -0
- package/dist/{chunk-FU52GL2E.js.map → chunk-DEPJRTVT.js.map} +1 -1
- package/dist/{chunk-472SOF76.js → chunk-DHTYHUYI.js} +85 -107
- package/dist/chunk-DHTYHUYI.js.map +1 -0
- package/dist/{chunk-FF5RF32O.js → chunk-E7WM2RXA.js} +3 -2
- package/dist/chunk-E7WM2RXA.js.map +1 -0
- package/dist/chunk-F6RZ7LW6.js +1271 -0
- package/dist/chunk-F6RZ7LW6.js.map +1 -0
- package/dist/chunk-FOGY3HA4.js +217 -0
- package/dist/chunk-FOGY3HA4.js.map +1 -0
- package/dist/chunk-G2GANYMW.js +139 -0
- package/dist/chunk-G2GANYMW.js.map +1 -0
- package/dist/chunk-I6DILPFE.js +293 -0
- package/dist/chunk-I6DILPFE.js.map +1 -0
- package/dist/{chunk-HOXFSQUV.js → chunk-IRYU3NTG.js} +2 -2
- package/dist/{chunk-HOXFSQUV.js.map → chunk-IRYU3NTG.js.map} +1 -1
- package/dist/chunk-JTIUGPW5.js +284 -0
- package/dist/chunk-JTIUGPW5.js.map +1 -0
- package/dist/{chunk-GUFHFEPZ.js → chunk-JZBSPDED.js} +2 -2
- package/dist/{chunk-GUFHFEPZ.js.map → chunk-JZBSPDED.js.map} +1 -1
- package/dist/{chunk-PFT2BNYO.js → chunk-KPY7TA4D.js} +5 -5
- package/dist/{chunk-PFT2BNYO.js.map → chunk-KPY7TA4D.js.map} +1 -1
- package/dist/{chunk-GMIE6III.js → chunk-LFWKGNCX.js} +50 -623
- package/dist/chunk-LFWKGNCX.js.map +1 -0
- package/dist/chunk-LH4ZZZYB.js +37 -0
- package/dist/chunk-LH4ZZZYB.js.map +1 -0
- package/dist/chunk-NFJ7CPG3.js +13 -0
- package/dist/chunk-NFJ7CPG3.js.map +1 -0
- package/dist/chunk-NFPOIHD4.js +3 -0
- package/dist/{chunk-JSQTYDPG.js.map → chunk-NFPOIHD4.js.map} +1 -1
- package/dist/{chunk-XIXSSI3B.js → chunk-NJM5AVBM.js} +3 -2
- package/dist/chunk-NJM5AVBM.js.map +1 -0
- package/dist/{chunk-4Z5DE5GK.js → chunk-NSNM53WI.js} +133 -115
- package/dist/chunk-NSNM53WI.js.map +1 -0
- package/dist/chunk-NTREGTG7.js +31 -0
- package/dist/chunk-NTREGTG7.js.map +1 -0
- package/dist/{chunk-ADG4HZEP.js → chunk-OKJA6SJM.js} +4 -4
- package/dist/chunk-OKJA6SJM.js.map +1 -0
- package/dist/{chunk-SU3LVQ7N.js → chunk-Q6JDNFSG.js} +11 -226
- package/dist/chunk-Q6JDNFSG.js.map +1 -0
- package/dist/chunk-RPOGINR5.js +115 -0
- package/dist/chunk-RPOGINR5.js.map +1 -0
- package/dist/{chunk-KQ67XB6T.js → chunk-RSWVYIXK.js} +151 -114
- package/dist/chunk-RSWVYIXK.js.map +1 -0
- package/dist/chunk-SSEHL5VP.js +110 -0
- package/dist/chunk-SSEHL5VP.js.map +1 -0
- package/dist/chunk-TEIGUOWN.js +523 -0
- package/dist/chunk-TEIGUOWN.js.map +1 -0
- package/dist/{chunk-AYYFMTMI.js → chunk-TJ7DHXUX.js} +2 -2
- package/dist/{chunk-AYYFMTMI.js.map → chunk-TJ7DHXUX.js.map} +1 -1
- package/dist/{chunk-75FQ5IW3.js → chunk-TZHWYT34.js} +3 -3
- package/dist/{chunk-75FQ5IW3.js.map → chunk-TZHWYT34.js.map} +1 -1
- package/dist/chunk-TZWHELY4.js +45 -0
- package/dist/chunk-TZWHELY4.js.map +1 -0
- package/dist/{chunk-OKTLA23Q.js → chunk-UEINJFLS.js} +6 -6
- package/dist/chunk-UEINJFLS.js.map +1 -0
- package/dist/chunk-URFQX3I6.js +129 -0
- package/dist/chunk-URFQX3I6.js.map +1 -0
- package/dist/chunk-VG6FOMOH.js +187 -0
- package/dist/chunk-VG6FOMOH.js.map +1 -0
- package/dist/{chunk-PGHEP4JD.js → chunk-VQVVHMPG.js} +3 -3
- package/dist/{chunk-PGHEP4JD.js.map → chunk-VQVVHMPG.js.map} +1 -1
- package/dist/{chunk-DRFNMZLG.js → chunk-VUKOT432.js} +3 -2
- package/dist/chunk-VUKOT432.js.map +1 -0
- package/dist/chunk-WD4N72DL.js +315 -0
- package/dist/chunk-WD4N72DL.js.map +1 -0
- package/dist/chunk-XBYMG4QK.js +119 -0
- package/dist/chunk-XBYMG4QK.js.map +1 -0
- package/dist/chunk-YHM6GIHV.js +3 -0
- package/dist/chunk-YHM6GIHV.js.map +1 -0
- package/dist/{chunk-SNZK5X6F.js → chunk-Z2AN43YU.js} +4 -2
- package/dist/chunk-Z2AN43YU.js.map +1 -0
- package/dist/chunk-ZNWHMQRM.js +171 -0
- package/dist/chunk-ZNWHMQRM.js.map +1 -0
- package/dist/{chunk-YSIG2XYH.js → chunk-ZRJYQN6Y.js} +2 -2
- package/dist/{chunk-YSIG2XYH.js.map → chunk-ZRJYQN6Y.js.map} +1 -1
- package/dist/{chunk-AD4W7HYC.js → chunk-ZYI3MHLE.js} +3 -2
- package/dist/chunk-ZYI3MHLE.js.map +1 -0
- package/dist/cli/index.js +59 -421
- package/dist/cli/index.js.map +1 -1
- package/dist/components/admin-filters/admin-data-table.d.ts +7 -1
- package/dist/components/admin-filters/admin-data-table.d.ts.map +1 -1
- package/dist/components/admin-filters/filter-toolbar.d.ts.map +1 -1
- package/dist/components/admin-filters/index.js +8 -0
- package/dist/components/admin-filters/index.js.map +1 -0
- package/dist/components/alert/alert.d.ts.map +1 -1
- package/dist/components/alert/index.js +5 -0
- package/dist/components/alert/index.js.map +1 -0
- package/dist/components/animate/index.js +5 -0
- package/dist/components/animate/index.js.map +1 -0
- package/dist/components/breadcrumbs/breadcrumbs.d.ts.map +1 -1
- package/dist/components/breadcrumbs/index.js +4 -0
- package/dist/components/breadcrumbs/index.js.map +1 -0
- package/dist/components/card/index.js +4 -0
- package/dist/components/card/index.js.map +1 -0
- package/dist/components/chart/chart.d.ts.map +1 -1
- package/dist/components/chart/index.css +52 -0
- package/dist/components/chart/index.css.map +1 -0
- package/dist/components/chart/index.js +5 -0
- package/dist/components/chart/index.js.map +1 -0
- package/dist/components/chart/types.d.ts +3 -1
- package/dist/components/chart/types.d.ts.map +1 -1
- package/dist/components/chart/use-chart.d.ts.map +1 -1
- package/dist/components/command-palette/command-palette.d.ts +3 -1
- package/dist/components/command-palette/command-palette.d.ts.map +1 -1
- package/dist/components/command-palette/index.js +4 -0
- package/dist/components/command-palette/index.js.map +1 -0
- package/dist/components/confirm-dialog/index.js +4 -0
- package/dist/components/confirm-dialog/index.js.map +1 -0
- package/dist/components/date-input/date-input.d.ts +1 -0
- package/dist/components/date-input/date-input.d.ts.map +1 -1
- package/dist/components/date-input/index.d.ts +0 -1
- package/dist/components/date-input/index.d.ts.map +1 -1
- package/dist/components/doc-layout/index.js +5 -4
- package/dist/components/doc-layout/index.js.map +1 -1
- package/dist/components/editor/index.js +4 -3
- package/dist/components/editor/index.js.map +1 -1
- package/dist/components/emoji-picker/index.js +2 -1
- package/dist/components/emoji-picker/index.js.map +1 -1
- package/dist/components/empty-content/empty-content.d.ts.map +1 -1
- package/dist/components/empty-content/index.js +4 -0
- package/dist/components/empty-content/index.js.map +1 -0
- package/dist/components/error-boundary/index.js +6 -0
- package/dist/components/error-boundary/index.js.map +1 -0
- package/dist/components/index.css +13 -10
- package/dist/components/index.css.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +47 -21
- package/dist/components/index.js.map +1 -1
- package/dist/components/knowledge-graph/edge-labels.d.ts.map +1 -1
- package/dist/components/knowledge-graph/index.js +18 -16
- package/dist/components/knowledge-graph/index.js.map +1 -1
- package/dist/components/label/index.js +5 -0
- package/dist/components/label/index.js.map +1 -0
- package/dist/components/label/label.d.ts.map +1 -1
- package/dist/components/loading-screen/index.js +4 -0
- package/dist/components/loading-screen/index.js.map +1 -0
- package/dist/components/map/MapPointPicker.d.ts.map +1 -1
- package/dist/components/map/index.js +2 -1
- package/dist/components/map/index.js.map +1 -1
- package/dist/components/navigation-progress/index.js +4 -0
- package/dist/components/navigation-progress/index.js.map +1 -0
- package/dist/components/page-content/index.js +4 -0
- package/dist/components/page-content/index.js.map +1 -0
- package/dist/components/popover/index.js +4 -0
- package/dist/components/popover/index.js.map +1 -0
- package/dist/components/research/diagram.d.ts.map +1 -1
- package/dist/components/research/index.js +6 -4
- package/dist/components/research/index.js.map +1 -1
- package/dist/components/research-editor/extensions.d.ts +1 -1
- package/dist/components/research-editor/index.js +11 -10
- package/dist/components/research-editor/index.js.map +1 -1
- package/dist/components/research-editor/math-navigation.d.ts +2 -2
- package/dist/components/research-editor/math-navigation.d.ts.map +1 -1
- package/dist/components/scroll-to-top/index.js +4 -0
- package/dist/components/scroll-to-top/index.js.map +1 -0
- package/dist/components/search-input/index.js +7 -0
- package/dist/components/search-input/index.js.map +1 -0
- package/dist/components/search-input/search-input.d.ts +3 -1
- package/dist/components/search-input/search-input.d.ts.map +1 -1
- package/dist/components/skeleton/index.js +4 -0
- package/dist/components/skeleton/index.js.map +1 -0
- package/dist/components/snackbar/index.js +6 -0
- package/dist/components/snackbar/index.js.map +1 -0
- package/dist/components/stepper/index.js +4 -0
- package/dist/components/stepper/index.js.map +1 -0
- package/dist/components/table/index.d.ts +1 -0
- package/dist/components/table/index.d.ts.map +1 -1
- package/dist/components/table/index.js +5 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/table/table-viewport.d.ts +13 -0
- package/dist/components/table/table-viewport.d.ts.map +1 -0
- package/dist/components/table/table.d.ts +3 -1
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/tabs/index.js +6 -0
- package/dist/components/tabs/index.js.map +1 -0
- package/dist/components/tabs/tabs.d.ts +12 -1
- package/dist/components/tabs/tabs.d.ts.map +1 -1
- package/dist/core/index.js +12 -10
- package/dist/core/index.js.map +1 -1
- package/dist/forms/index.js +2 -0
- package/dist/forms/index.js.map +1 -1
- package/dist/hooks/index.js +14 -12
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/use-config-from-query.d.ts +2 -0
- package/dist/hooks/use-config-from-query.d.ts.map +1 -1
- package/dist/hooks/use-image-dimensions.d.ts.map +1 -1
- package/dist/hooks/use-keyboard-shortcut.d.ts.map +1 -1
- package/dist/hooks/use-scroll-position.d.ts.map +1 -1
- package/dist/hooks/use-window-size.d.ts.map +1 -1
- package/dist/icons/context.d.ts.map +1 -1
- package/dist/icons/index.js +3 -2
- package/dist/icons/index.js.map +1 -1
- package/dist/index.css +13 -10
- package/dist/index.css.map +1 -1
- package/dist/index.js +57 -31
- package/dist/index.js.map +1 -1
- package/dist/internal/research-parser.js +3 -0
- package/dist/internal/research-parser.js.map +1 -0
- package/dist/layouts/core/header-section.d.ts +1 -0
- package/dist/layouts/core/header-section.d.ts.map +1 -1
- package/dist/layouts/dashboard/layout.d.ts +3 -1
- package/dist/layouts/dashboard/layout.d.ts.map +1 -1
- package/dist/layouts/dashboard/sidenav.d.ts.map +1 -1
- package/dist/layouts/index.js +9 -8
- package/dist/layouts/index.js.map +1 -1
- package/dist/netron/index.js +2 -1
- package/dist/netron/index.js.map +1 -1
- package/dist/registry/index.js +1 -1
- package/dist/state/create-store.d.ts.map +1 -1
- package/dist/state/index.js +3 -2
- package/dist/state/index.js.map +1 -1
- package/dist/state/settings-version.d.ts.map +1 -1
- package/dist/theme/components/Chip.d.ts.map +1 -1
- package/dist/theme/components/Dialog.d.ts.map +1 -1
- package/dist/theme/components/TextField.d.ts.map +1 -1
- package/dist/theme/components/index.d.ts.map +1 -1
- package/dist/theme/components/theme-utils.d.ts +2 -2
- package/dist/theme/components/theme-utils.d.ts.map +1 -1
- package/dist/theme/index.js +8 -6
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/palette/overrides.d.ts +1 -0
- package/dist/theme/palette/overrides.d.ts.map +1 -1
- package/dist/theme/semantic-surface.d.ts +8 -0
- package/dist/theme/semantic-surface.d.ts.map +1 -0
- package/dist/types/index.js +2 -2
- package/dist/ui/index.js +6 -5
- package/dist/ui/index.js.map +1 -1
- package/dist/utils/async-lock.d.ts.map +1 -1
- package/package.json +143 -37
- package/dist/chunk-472SOF76.js.map +0 -1
- package/dist/chunk-4Z5DE5GK.js.map +0 -1
- package/dist/chunk-52PQL67Q.js.map +0 -1
- package/dist/chunk-AD4W7HYC.js.map +0 -1
- package/dist/chunk-ADG4HZEP.js.map +0 -1
- package/dist/chunk-BJE2AKD4.js.map +0 -1
- package/dist/chunk-BRDWQVRT.js.map +0 -1
- package/dist/chunk-DRFNMZLG.js.map +0 -1
- package/dist/chunk-FF5RF32O.js.map +0 -1
- package/dist/chunk-FU52GL2E.js +0 -3
- package/dist/chunk-GMIE6III.js.map +0 -1
- package/dist/chunk-JSQTYDPG.js +0 -3
- package/dist/chunk-KQ67XB6T.js.map +0 -1
- package/dist/chunk-LSPFFEJT.js.map +0 -1
- package/dist/chunk-OKTLA23Q.js.map +0 -1
- package/dist/chunk-SNZK5X6F.js.map +0 -1
- package/dist/chunk-SU3LVQ7N.js.map +0 -1
- package/dist/chunk-XIXSSI3B.js.map +0 -1
package/dist/cli/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
|
-
import * as
|
|
2
|
+
import * as fs5 from 'fs';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import { Command } from 'commander';
|
|
5
5
|
import * as readline from 'readline';
|
|
@@ -89,7 +89,7 @@ function findConfigFile(startDir = process.cwd()) {
|
|
|
89
89
|
const root = path.parse(currentDir).root;
|
|
90
90
|
while (currentDir !== root) {
|
|
91
91
|
const configPath = path.join(currentDir, CONFIG_FILE_NAME);
|
|
92
|
-
if (
|
|
92
|
+
if (fs5.existsSync(configPath)) {
|
|
93
93
|
return configPath;
|
|
94
94
|
}
|
|
95
95
|
currentDir = path.dirname(currentDir);
|
|
@@ -102,7 +102,7 @@ async function loadConfig(cwd = process.cwd()) {
|
|
|
102
102
|
return null;
|
|
103
103
|
}
|
|
104
104
|
try {
|
|
105
|
-
const content = await
|
|
105
|
+
const content = await fs5.promises.readFile(configPath, "utf-8");
|
|
106
106
|
const config = JSON.parse(content);
|
|
107
107
|
return {
|
|
108
108
|
...DEFAULT_CONFIG,
|
|
@@ -117,7 +117,7 @@ async function loadConfig(cwd = process.cwd()) {
|
|
|
117
117
|
}
|
|
118
118
|
async function saveConfig(config, outputPath = path.join(process.cwd(), CONFIG_FILE_NAME)) {
|
|
119
119
|
const content = JSON.stringify(config, null, 2);
|
|
120
|
-
await
|
|
120
|
+
await fs5.promises.writeFile(outputPath, content, "utf-8");
|
|
121
121
|
}
|
|
122
122
|
function resolveAlias(alias, config) {
|
|
123
123
|
if (alias.startsWith("@/")) {
|
|
@@ -145,372 +145,10 @@ var init_config = __esm({
|
|
|
145
145
|
}
|
|
146
146
|
});
|
|
147
147
|
|
|
148
|
-
// src/registry/manager.ts
|
|
149
|
-
var RegistryManager;
|
|
150
|
-
var init_manager = __esm({
|
|
151
|
-
"src/registry/manager.ts"() {
|
|
152
|
-
RegistryManager = class {
|
|
153
|
-
options;
|
|
154
|
-
registries = /* @__PURE__ */ new Map();
|
|
155
|
-
cache = /* @__PURE__ */ new Map();
|
|
156
|
-
loaders = /* @__PURE__ */ new Map();
|
|
157
|
-
constructor(options = {}) {
|
|
158
|
-
this.options = {
|
|
159
|
-
baseDir: options.baseDir ?? (typeof process !== "undefined" && process.cwd ? process.cwd() : "/"),
|
|
160
|
-
defaultRegistry: options.defaultRegistry ?? "prism",
|
|
161
|
-
config: options.config ?? { default: "prism", registries: {} },
|
|
162
|
-
cacheTtl: options.cacheTtl ?? 5 * 60 * 1e3
|
|
163
|
-
// 5 minutes
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
// ===========================================================================
|
|
167
|
-
// REGISTRY LOADING
|
|
168
|
-
// ===========================================================================
|
|
169
|
-
/**
|
|
170
|
-
* Register a custom loader for a registry.
|
|
171
|
-
*/
|
|
172
|
-
registerLoader(name, loader) {
|
|
173
|
-
this.loaders.set(name, loader);
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Load a registry by name.
|
|
177
|
-
*/
|
|
178
|
-
async loadRegistry(name) {
|
|
179
|
-
const cached = this.cache.get(name);
|
|
180
|
-
if (cached && Date.now() - cached.timestamp < this.options.cacheTtl) {
|
|
181
|
-
return cached.data;
|
|
182
|
-
}
|
|
183
|
-
const existing = this.registries.get(name);
|
|
184
|
-
if (existing && !cached) {
|
|
185
|
-
return existing;
|
|
186
|
-
}
|
|
187
|
-
const customLoader = this.loaders.get(name);
|
|
188
|
-
if (customLoader) {
|
|
189
|
-
const registry3 = await customLoader();
|
|
190
|
-
this.cacheRegistry(name, registry3);
|
|
191
|
-
return registry3;
|
|
192
|
-
}
|
|
193
|
-
const config = this.options.config.registries[name];
|
|
194
|
-
if (!config) {
|
|
195
|
-
throw new Error(`Registry "${name}" not found in configuration`);
|
|
196
|
-
}
|
|
197
|
-
const registry2 = typeof config === "string" ? await this.loadFromPath(config) : await this.loadFromRemote(config);
|
|
198
|
-
if (registry2.extends) {
|
|
199
|
-
const baseRegistry = await this.loadRegistry(registry2.extends);
|
|
200
|
-
const merged = this.mergeRegistries(baseRegistry, registry2);
|
|
201
|
-
this.cacheRegistry(name, merged);
|
|
202
|
-
return merged;
|
|
203
|
-
}
|
|
204
|
-
this.cacheRegistry(name, registry2);
|
|
205
|
-
return registry2;
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Load registry from local file path.
|
|
209
|
-
* Uses dynamic import for ESM compatibility across environments.
|
|
210
|
-
*
|
|
211
|
-
* @param path - Relative or absolute path to registry JSON
|
|
212
|
-
* @returns Loaded registry schema
|
|
213
|
-
*/
|
|
214
|
-
async loadFromPath(path9) {
|
|
215
|
-
const fullPath = path9.startsWith("/") ? path9 : `${this.options.baseDir}/${path9}`;
|
|
216
|
-
if (typeof process !== "undefined" && (process.versions?.node || process.versions?.bun)) {
|
|
217
|
-
const fs9 = await import('fs/promises');
|
|
218
|
-
const content = await fs9.readFile(fullPath, "utf-8");
|
|
219
|
-
return JSON.parse(content);
|
|
220
|
-
}
|
|
221
|
-
if (path9.startsWith("http://") || path9.startsWith("https://")) {
|
|
222
|
-
const response = await fetch(path9);
|
|
223
|
-
if (!response.ok) {
|
|
224
|
-
throw new Error(`Failed to load registry from ${path9}: ${response.statusText}`);
|
|
225
|
-
}
|
|
226
|
-
return response.json();
|
|
227
|
-
}
|
|
228
|
-
throw new Error(
|
|
229
|
-
`Cannot load local file "${fullPath}" in browser environment. Register a custom loader with manager.registerLoader() or use a remote URL.`
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Load registry from remote URL.
|
|
234
|
-
*/
|
|
235
|
-
async loadFromRemote(config) {
|
|
236
|
-
const response = await fetch(config.url, {
|
|
237
|
-
headers: config.headers
|
|
238
|
-
});
|
|
239
|
-
if (!response.ok) {
|
|
240
|
-
throw new Error(`Failed to load registry from ${config.url}: ${response.statusText}`);
|
|
241
|
-
}
|
|
242
|
-
return response.json();
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Cache a loaded registry.
|
|
246
|
-
*/
|
|
247
|
-
cacheRegistry(name, registry2) {
|
|
248
|
-
this.registries.set(name, registry2);
|
|
249
|
-
this.cache.set(name, {
|
|
250
|
-
data: registry2,
|
|
251
|
-
timestamp: Date.now()
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Merge two registries (base + extension).
|
|
256
|
-
*/
|
|
257
|
-
mergeRegistries(base, extension) {
|
|
258
|
-
return {
|
|
259
|
-
...base,
|
|
260
|
-
...extension,
|
|
261
|
-
components: { ...base.components, ...extension.components },
|
|
262
|
-
blocks: { ...base.blocks, ...extension.blocks },
|
|
263
|
-
themes: { ...base.themes, ...extension.themes }
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Clear registry cache.
|
|
268
|
-
*/
|
|
269
|
-
clearCache(name) {
|
|
270
|
-
if (name) {
|
|
271
|
-
this.cache.delete(name);
|
|
272
|
-
} else {
|
|
273
|
-
this.cache.clear();
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
// ===========================================================================
|
|
277
|
-
// COMPONENT OPERATIONS
|
|
278
|
-
// ===========================================================================
|
|
279
|
-
/**
|
|
280
|
-
* Get a component definition by name.
|
|
281
|
-
*/
|
|
282
|
-
async getComponent(name, registryName) {
|
|
283
|
-
const registry2 = await this.loadRegistry(registryName ?? this.options.defaultRegistry);
|
|
284
|
-
return registry2.components[name] ?? null;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Get all components from a registry.
|
|
288
|
-
*/
|
|
289
|
-
async getComponents(registryName) {
|
|
290
|
-
const registry2 = await this.loadRegistry(registryName ?? this.options.defaultRegistry);
|
|
291
|
-
return registry2.components;
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Search for components.
|
|
295
|
-
*/
|
|
296
|
-
async searchComponents(options, registryName) {
|
|
297
|
-
const registry2 = await this.loadRegistry(registryName ?? this.options.defaultRegistry);
|
|
298
|
-
let results = Object.values(registry2.components);
|
|
299
|
-
if (options.category) {
|
|
300
|
-
results = results.filter((c) => c.category === options.category);
|
|
301
|
-
}
|
|
302
|
-
if (options.query) {
|
|
303
|
-
const query = options.query.toLowerCase();
|
|
304
|
-
results = results.filter(
|
|
305
|
-
(c) => c.name.toLowerCase().includes(query) || c.displayName?.toLowerCase().includes(query) || c.description?.toLowerCase().includes(query)
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
if (options.limit && options.limit > 0) {
|
|
309
|
-
results = results.slice(0, options.limit);
|
|
310
|
-
}
|
|
311
|
-
return results;
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Get component categories.
|
|
315
|
-
*/
|
|
316
|
-
async getComponentCategories(registryName) {
|
|
317
|
-
const registry2 = await this.loadRegistry(registryName ?? this.options.defaultRegistry);
|
|
318
|
-
const categories = /* @__PURE__ */ new Set();
|
|
319
|
-
for (const component of Object.values(registry2.components)) {
|
|
320
|
-
categories.add(component.category);
|
|
321
|
-
}
|
|
322
|
-
return Array.from(categories).sort();
|
|
323
|
-
}
|
|
324
|
-
// ===========================================================================
|
|
325
|
-
// BLOCK OPERATIONS
|
|
326
|
-
// ===========================================================================
|
|
327
|
-
/**
|
|
328
|
-
* Get a block definition by name.
|
|
329
|
-
*/
|
|
330
|
-
async getBlock(name, registryName) {
|
|
331
|
-
const registry2 = await this.loadRegistry(registryName ?? this.options.defaultRegistry);
|
|
332
|
-
return registry2.blocks[name] ?? null;
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Get all blocks from a registry.
|
|
336
|
-
*/
|
|
337
|
-
async getBlocks(registryName) {
|
|
338
|
-
const registry2 = await this.loadRegistry(registryName ?? this.options.defaultRegistry);
|
|
339
|
-
return registry2.blocks;
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* Search for blocks.
|
|
343
|
-
*/
|
|
344
|
-
async searchBlocks(options, registryName) {
|
|
345
|
-
const registry2 = await this.loadRegistry(registryName ?? this.options.defaultRegistry);
|
|
346
|
-
let results = Object.values(registry2.blocks);
|
|
347
|
-
if (options.category) {
|
|
348
|
-
results = results.filter((b) => b.category === options.category);
|
|
349
|
-
}
|
|
350
|
-
if (options.query) {
|
|
351
|
-
const query = options.query.toLowerCase();
|
|
352
|
-
results = results.filter(
|
|
353
|
-
(b) => b.name.toLowerCase().includes(query) || b.displayName?.toLowerCase().includes(query) || b.description?.toLowerCase().includes(query)
|
|
354
|
-
);
|
|
355
|
-
}
|
|
356
|
-
if (options.limit && options.limit > 0) {
|
|
357
|
-
results = results.slice(0, options.limit);
|
|
358
|
-
}
|
|
359
|
-
return results;
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Get block categories.
|
|
363
|
-
*/
|
|
364
|
-
async getBlockCategories(registryName) {
|
|
365
|
-
const registry2 = await this.loadRegistry(registryName ?? this.options.defaultRegistry);
|
|
366
|
-
const categories = /* @__PURE__ */ new Set();
|
|
367
|
-
for (const block of Object.values(registry2.blocks)) {
|
|
368
|
-
categories.add(block.category);
|
|
369
|
-
}
|
|
370
|
-
return Array.from(categories).sort();
|
|
371
|
-
}
|
|
372
|
-
// ===========================================================================
|
|
373
|
-
// DEPENDENCY RESOLUTION
|
|
374
|
-
// ===========================================================================
|
|
375
|
-
/**
|
|
376
|
-
* Resolve all dependencies for a component.
|
|
377
|
-
*/
|
|
378
|
-
async resolveComponentDependencies(name, registryName) {
|
|
379
|
-
const registry2 = registryName ?? this.options.defaultRegistry;
|
|
380
|
-
const component = await this.getComponent(name, registry2);
|
|
381
|
-
if (!component) {
|
|
382
|
-
throw new Error(`Component "${name}" not found in registry "${registry2}"`);
|
|
383
|
-
}
|
|
384
|
-
const dependencies = [];
|
|
385
|
-
for (const depName of component.dependencies.components) {
|
|
386
|
-
const resolved = await this.resolveComponentDependencies(depName, registry2);
|
|
387
|
-
dependencies.push(resolved);
|
|
388
|
-
}
|
|
389
|
-
return {
|
|
390
|
-
definition: component,
|
|
391
|
-
registry: registry2,
|
|
392
|
-
dependencies
|
|
393
|
-
};
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Resolve all dependencies for a block.
|
|
397
|
-
*/
|
|
398
|
-
async resolveBlockDependencies(name, registryName) {
|
|
399
|
-
const registry2 = registryName ?? this.options.defaultRegistry;
|
|
400
|
-
const block = await this.getBlock(name, registry2);
|
|
401
|
-
if (!block) {
|
|
402
|
-
throw new Error(`Block "${name}" not found in registry "${registry2}"`);
|
|
403
|
-
}
|
|
404
|
-
const dependencies = [];
|
|
405
|
-
for (const compName of block.dependencies.components) {
|
|
406
|
-
const resolved = await this.resolveComponentDependencies(compName, registry2);
|
|
407
|
-
dependencies.push(resolved);
|
|
408
|
-
}
|
|
409
|
-
for (const blockName of block.dependencies.blocks) {
|
|
410
|
-
const resolved = await this.resolveBlockDependencies(blockName, registry2);
|
|
411
|
-
dependencies.push(resolved);
|
|
412
|
-
}
|
|
413
|
-
return {
|
|
414
|
-
definition: block,
|
|
415
|
-
registry: registry2,
|
|
416
|
-
dependencies
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* Get flat list of all npm dependencies for resolved items.
|
|
421
|
-
*/
|
|
422
|
-
getNpmDependencies(resolved) {
|
|
423
|
-
const deps = /* @__PURE__ */ new Set();
|
|
424
|
-
function collectDeps(item) {
|
|
425
|
-
const definition = item.definition;
|
|
426
|
-
if ("dependencies" in definition) {
|
|
427
|
-
for (const dep of definition.dependencies.npm) {
|
|
428
|
-
deps.add(dep);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
for (const child of item.dependencies) {
|
|
432
|
-
collectDeps(child);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
collectDeps(resolved);
|
|
436
|
-
return Array.from(deps).sort();
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* Get flat list of all file paths for resolved items.
|
|
440
|
-
*/
|
|
441
|
-
getFilePaths(resolved) {
|
|
442
|
-
const paths = /* @__PURE__ */ new Set();
|
|
443
|
-
function collectPaths(item) {
|
|
444
|
-
const definition = item.definition;
|
|
445
|
-
for (const file of definition.files) {
|
|
446
|
-
paths.add(file.path);
|
|
447
|
-
}
|
|
448
|
-
for (const child of item.dependencies) {
|
|
449
|
-
collectPaths(child);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
collectPaths(resolved);
|
|
453
|
-
return Array.from(paths).sort();
|
|
454
|
-
}
|
|
455
|
-
// ===========================================================================
|
|
456
|
-
// VERSION CHECKING
|
|
457
|
-
// ===========================================================================
|
|
458
|
-
/**
|
|
459
|
-
* Check if a component version is compatible.
|
|
460
|
-
*/
|
|
461
|
-
async checkComponentVersion(name, requiredVersion, registryName) {
|
|
462
|
-
const component = await this.getComponent(name, registryName);
|
|
463
|
-
if (!component) return false;
|
|
464
|
-
return this.isVersionCompatible(component.version, requiredVersion);
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* Check semver version compatibility.
|
|
468
|
-
* Simple implementation - considers major.minor compatibility.
|
|
469
|
-
*/
|
|
470
|
-
isVersionCompatible(actual, required) {
|
|
471
|
-
const [actualMajor, actualMinor] = actual.split(".").map(Number);
|
|
472
|
-
const [requiredMajor, requiredMinor] = required.split(".").map(Number);
|
|
473
|
-
if (actualMajor !== requiredMajor) return false;
|
|
474
|
-
return actualMinor >= requiredMinor;
|
|
475
|
-
}
|
|
476
|
-
// ===========================================================================
|
|
477
|
-
// REGISTRY INFO
|
|
478
|
-
// ===========================================================================
|
|
479
|
-
/**
|
|
480
|
-
* Get registry metadata.
|
|
481
|
-
*/
|
|
482
|
-
async getRegistryInfo(registryName) {
|
|
483
|
-
const registry2 = await this.loadRegistry(registryName ?? this.options.defaultRegistry);
|
|
484
|
-
return {
|
|
485
|
-
name: registry2.name,
|
|
486
|
-
version: registry2.version,
|
|
487
|
-
description: registry2.description,
|
|
488
|
-
componentCount: Object.keys(registry2.components).length,
|
|
489
|
-
blockCount: Object.keys(registry2.blocks).length,
|
|
490
|
-
themeCount: Object.keys(registry2.themes).length
|
|
491
|
-
};
|
|
492
|
-
}
|
|
493
|
-
/**
|
|
494
|
-
* Get list of loaded registries.
|
|
495
|
-
*/
|
|
496
|
-
getLoadedRegistries() {
|
|
497
|
-
return Array.from(this.registries.keys());
|
|
498
|
-
}
|
|
499
|
-
};
|
|
500
|
-
new RegistryManager();
|
|
501
|
-
}
|
|
502
|
-
});
|
|
503
|
-
var init_installer = __esm({
|
|
504
|
-
"src/registry/installer.ts"() {
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
|
|
508
148
|
// src/registry/index.ts
|
|
509
149
|
var defaultRegistrySchema;
|
|
510
150
|
var init_registry = __esm({
|
|
511
151
|
"src/registry/index.ts"() {
|
|
512
|
-
init_manager();
|
|
513
|
-
init_installer();
|
|
514
152
|
defaultRegistrySchema = {
|
|
515
153
|
$schema: "https://prism.omnitron.dev/registry/v1/schema.json",
|
|
516
154
|
name: "prism",
|
|
@@ -1205,15 +843,15 @@ async function runAdd(items, options) {
|
|
|
1205
843
|
console.log("");
|
|
1206
844
|
}
|
|
1207
845
|
function detectPackageManager(cwd) {
|
|
1208
|
-
if (
|
|
1209
|
-
if (
|
|
846
|
+
if (fs5.existsSync(path.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
847
|
+
if (fs5.existsSync(path.join(cwd, "yarn.lock"))) return "yarn";
|
|
1210
848
|
return "npm";
|
|
1211
849
|
}
|
|
1212
850
|
async function addItem(item, config, options) {
|
|
1213
851
|
const isBlock = item.startsWith("block:");
|
|
1214
852
|
const itemName = isBlock ? item.slice(6) : item;
|
|
1215
|
-
const
|
|
1216
|
-
const definition =
|
|
853
|
+
const registry = isBlock ? defaultRegistrySchema.blocks : defaultRegistrySchema.components;
|
|
854
|
+
const definition = registry[itemName];
|
|
1217
855
|
if (!definition) {
|
|
1218
856
|
return {
|
|
1219
857
|
name: item,
|
|
@@ -1222,18 +860,18 @@ async function addItem(item, config, options) {
|
|
|
1222
860
|
};
|
|
1223
861
|
}
|
|
1224
862
|
const outputPath = options.path ? path.join(config.rootDir, options.path, itemName) : isBlock ? getBlockPath(itemName, config) : getComponentPath(itemName, config);
|
|
1225
|
-
if (
|
|
863
|
+
if (fs5.existsSync(outputPath) && !options.overwrite) {
|
|
1226
864
|
return {
|
|
1227
865
|
name: item,
|
|
1228
866
|
success: false,
|
|
1229
867
|
error: `Already exists at ${path.relative(config.rootDir, outputPath)}. Use --overwrite to replace.`
|
|
1230
868
|
};
|
|
1231
869
|
}
|
|
1232
|
-
await
|
|
870
|
+
await fs5.promises.mkdir(outputPath, { recursive: true });
|
|
1233
871
|
for (const file of definition.files) {
|
|
1234
872
|
const filePath = path.join(outputPath, file.path);
|
|
1235
873
|
const content = generateFileContent(itemName, file.path, file.type, definition, isBlock);
|
|
1236
|
-
await
|
|
874
|
+
await fs5.promises.writeFile(filePath, content, "utf-8");
|
|
1237
875
|
}
|
|
1238
876
|
log.success(`Added ${itemName} \u2192 ${path.relative(config.rootDir, outputPath)}/`);
|
|
1239
877
|
await updateLockfile(config.rootDir, itemName, definition.version, isBlock);
|
|
@@ -1250,9 +888,9 @@ async function updateLockfile(rootDir, name, version, isBlock) {
|
|
|
1250
888
|
components: {},
|
|
1251
889
|
blocks: {}
|
|
1252
890
|
};
|
|
1253
|
-
if (
|
|
891
|
+
if (fs5.existsSync(lockfilePath)) {
|
|
1254
892
|
try {
|
|
1255
|
-
lockfile = JSON.parse(await
|
|
893
|
+
lockfile = JSON.parse(await fs5.promises.readFile(lockfilePath, "utf-8"));
|
|
1256
894
|
} catch {
|
|
1257
895
|
}
|
|
1258
896
|
}
|
|
@@ -1266,7 +904,7 @@ async function updateLockfile(rootDir, name, version, isBlock) {
|
|
|
1266
904
|
} else {
|
|
1267
905
|
lockfile.components[name] = entry;
|
|
1268
906
|
}
|
|
1269
|
-
await
|
|
907
|
+
await fs5.promises.writeFile(lockfilePath, JSON.stringify(lockfile, null, 2) + "\n", "utf-8");
|
|
1270
908
|
}
|
|
1271
909
|
function toPascalCase(name) {
|
|
1272
910
|
return name.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
@@ -1874,11 +1512,11 @@ async function prompt(question, defaultValue) {
|
|
|
1874
1512
|
input: process.stdin,
|
|
1875
1513
|
output: process.stdout
|
|
1876
1514
|
});
|
|
1877
|
-
return new Promise((
|
|
1515
|
+
return new Promise((resolve2) => {
|
|
1878
1516
|
const displayQuestion = defaultValue ? `${question} (${defaultValue}): ` : `${question}: `;
|
|
1879
1517
|
rl.question(displayQuestion, (answer) => {
|
|
1880
1518
|
rl.close();
|
|
1881
|
-
|
|
1519
|
+
resolve2(answer.trim() || defaultValue || "");
|
|
1882
1520
|
});
|
|
1883
1521
|
});
|
|
1884
1522
|
}
|
|
@@ -1924,8 +1562,8 @@ async function runInit(options) {
|
|
|
1924
1562
|
path.join(cwd, DEFAULT_UTILS_DIR)
|
|
1925
1563
|
];
|
|
1926
1564
|
for (const dir of dirs) {
|
|
1927
|
-
if (!
|
|
1928
|
-
await
|
|
1565
|
+
if (!fs5.existsSync(dir)) {
|
|
1566
|
+
await fs5.promises.mkdir(dir, { recursive: true });
|
|
1929
1567
|
log.success(`Created ${path.relative(cwd, dir)}/`);
|
|
1930
1568
|
}
|
|
1931
1569
|
}
|
|
@@ -1951,7 +1589,7 @@ async function interactiveInit(cwd) {
|
|
|
1951
1589
|
const utilsAlias = await prompt("Where should utils be installed?", "@/utils");
|
|
1952
1590
|
const tailwindConfigPath = path.join(cwd, "tailwind.config.js");
|
|
1953
1591
|
const tailwindTsConfigPath = path.join(cwd, "tailwind.config.ts");
|
|
1954
|
-
const hasTailwind =
|
|
1592
|
+
const hasTailwind = fs5.existsSync(tailwindConfigPath) || fs5.existsSync(tailwindTsConfigPath);
|
|
1955
1593
|
let tailwindConfig;
|
|
1956
1594
|
if (hasTailwind) {
|
|
1957
1595
|
const useTailwind = await confirm("Tailwind CSS detected. Configure CSS variables?", true);
|
|
@@ -1959,7 +1597,7 @@ async function interactiveInit(cwd) {
|
|
|
1959
1597
|
const cssFile = await prompt("Where is your global CSS file?", "src/index.css");
|
|
1960
1598
|
const baseColor = await prompt("What base color would you like?", "slate");
|
|
1961
1599
|
tailwindConfig = {
|
|
1962
|
-
config:
|
|
1600
|
+
config: fs5.existsSync(tailwindTsConfigPath) ? "tailwind.config.ts" : "tailwind.config.js",
|
|
1963
1601
|
css: cssFile,
|
|
1964
1602
|
baseColor,
|
|
1965
1603
|
cssVariables: true
|
|
@@ -2123,8 +1761,8 @@ async function runDiff(items, options) {
|
|
|
2123
1761
|
async function findInstalledItems(config, filterItems) {
|
|
2124
1762
|
const items = [];
|
|
2125
1763
|
const componentsDir = getComponentPath("", config);
|
|
2126
|
-
if (
|
|
2127
|
-
const entries = await
|
|
1764
|
+
if (fs5.existsSync(componentsDir)) {
|
|
1765
|
+
const entries = await fs5.promises.readdir(componentsDir, { withFileTypes: true });
|
|
2128
1766
|
for (const entry of entries) {
|
|
2129
1767
|
if (entry.isDirectory()) {
|
|
2130
1768
|
const name = entry.name;
|
|
@@ -2139,8 +1777,8 @@ async function findInstalledItems(config, filterItems) {
|
|
|
2139
1777
|
}
|
|
2140
1778
|
}
|
|
2141
1779
|
const blocksDir = getBlockPath("", config);
|
|
2142
|
-
if (
|
|
2143
|
-
const entries = await
|
|
1780
|
+
if (fs5.existsSync(blocksDir)) {
|
|
1781
|
+
const entries = await fs5.promises.readdir(blocksDir, { withFileTypes: true });
|
|
2144
1782
|
for (const entry of entries) {
|
|
2145
1783
|
if (entry.isDirectory()) {
|
|
2146
1784
|
const name = entry.name;
|
|
@@ -2157,16 +1795,16 @@ async function findInstalledItems(config, filterItems) {
|
|
|
2157
1795
|
return items;
|
|
2158
1796
|
}
|
|
2159
1797
|
async function checkItemStatus(item, config) {
|
|
2160
|
-
const
|
|
2161
|
-
const definition =
|
|
1798
|
+
const registry = item.type === "block" ? defaultRegistrySchema.blocks : defaultRegistrySchema.components;
|
|
1799
|
+
const definition = registry[item.name];
|
|
2162
1800
|
if (!definition) {
|
|
2163
1801
|
return "unknown";
|
|
2164
1802
|
}
|
|
2165
1803
|
const lockfilePath = path.join(config.rootDir, "prism.lock.json");
|
|
2166
1804
|
let installedVersion;
|
|
2167
|
-
if (
|
|
1805
|
+
if (fs5.existsSync(lockfilePath)) {
|
|
2168
1806
|
try {
|
|
2169
|
-
const lockfile = JSON.parse(await
|
|
1807
|
+
const lockfile = JSON.parse(await fs5.promises.readFile(lockfilePath, "utf-8"));
|
|
2170
1808
|
const installed = item.type === "block" ? lockfile.blocks?.[item.name] : lockfile.components?.[item.name];
|
|
2171
1809
|
installedVersion = installed?.version;
|
|
2172
1810
|
} catch {
|
|
@@ -2184,11 +1822,11 @@ async function checkItemStatus(item, config) {
|
|
|
2184
1822
|
async function checkForLocalModifications(item, definition, _config) {
|
|
2185
1823
|
for (const file of definition.files) {
|
|
2186
1824
|
const filePath = path.join(item.path, file.path);
|
|
2187
|
-
if (!
|
|
1825
|
+
if (!fs5.existsSync(filePath)) {
|
|
2188
1826
|
return true;
|
|
2189
1827
|
}
|
|
2190
1828
|
}
|
|
2191
|
-
const localFiles = await
|
|
1829
|
+
const localFiles = await fs5.promises.readdir(item.path);
|
|
2192
1830
|
const expectedFiles = new Set(definition.files.map((f) => f.path));
|
|
2193
1831
|
for (const localFile of localFiles) {
|
|
2194
1832
|
if (localFile.startsWith(".") || localFile === "node_modules") {
|
|
@@ -2268,8 +1906,8 @@ async function runUpdate(items, options) {
|
|
|
2268
1906
|
async function findInstalledItems2(config, filterItems, all) {
|
|
2269
1907
|
const items = [];
|
|
2270
1908
|
const componentsDir = getComponentPath("", config);
|
|
2271
|
-
if (
|
|
2272
|
-
const entries = await
|
|
1909
|
+
if (fs5.existsSync(componentsDir)) {
|
|
1910
|
+
const entries = await fs5.promises.readdir(componentsDir, { withFileTypes: true });
|
|
2273
1911
|
for (const entry of entries) {
|
|
2274
1912
|
if (entry.isDirectory()) {
|
|
2275
1913
|
const name = entry.name;
|
|
@@ -2284,8 +1922,8 @@ async function findInstalledItems2(config, filterItems, all) {
|
|
|
2284
1922
|
}
|
|
2285
1923
|
}
|
|
2286
1924
|
const blocksDir = getBlockPath("", config);
|
|
2287
|
-
if (
|
|
2288
|
-
const entries = await
|
|
1925
|
+
if (fs5.existsSync(blocksDir)) {
|
|
1926
|
+
const entries = await fs5.promises.readdir(blocksDir, { withFileTypes: true });
|
|
2289
1927
|
for (const entry of entries) {
|
|
2290
1928
|
if (entry.isDirectory()) {
|
|
2291
1929
|
const name = entry.name;
|
|
@@ -2302,15 +1940,15 @@ async function findInstalledItems2(config, filterItems, all) {
|
|
|
2302
1940
|
return items;
|
|
2303
1941
|
}
|
|
2304
1942
|
async function checkForUpdate(item, config) {
|
|
2305
|
-
const
|
|
2306
|
-
const definition =
|
|
1943
|
+
const registry = item.type === "block" ? defaultRegistrySchema.blocks : defaultRegistrySchema.components;
|
|
1944
|
+
const definition = registry[item.name];
|
|
2307
1945
|
if (!definition) {
|
|
2308
1946
|
return false;
|
|
2309
1947
|
}
|
|
2310
1948
|
const lockfilePath = path.join(config.rootDir, "prism.lock.json");
|
|
2311
|
-
if (
|
|
1949
|
+
if (fs5.existsSync(lockfilePath)) {
|
|
2312
1950
|
try {
|
|
2313
|
-
const lockfile = JSON.parse(await
|
|
1951
|
+
const lockfile = JSON.parse(await fs5.promises.readFile(lockfilePath, "utf-8"));
|
|
2314
1952
|
const installed = item.type === "block" ? lockfile.blocks?.[item.name] : lockfile.components?.[item.name];
|
|
2315
1953
|
if (installed?.version && installed.version !== definition.version) {
|
|
2316
1954
|
return true;
|
|
@@ -2321,19 +1959,19 @@ async function checkForUpdate(item, config) {
|
|
|
2321
1959
|
return false;
|
|
2322
1960
|
}
|
|
2323
1961
|
async function updateItem(item, config, options) {
|
|
2324
|
-
const
|
|
2325
|
-
const definition =
|
|
1962
|
+
const registry = item.type === "block" ? defaultRegistrySchema.blocks : defaultRegistrySchema.components;
|
|
1963
|
+
const definition = registry[item.name];
|
|
2326
1964
|
if (!definition) {
|
|
2327
1965
|
throw new Error("Item not found in registry");
|
|
2328
1966
|
}
|
|
2329
1967
|
if (!options.overwrite) {
|
|
2330
1968
|
const backupDir = path.join(item.path, ".prism-backup");
|
|
2331
|
-
await
|
|
1969
|
+
await fs5.promises.mkdir(backupDir, { recursive: true });
|
|
2332
1970
|
for (const file of definition.files) {
|
|
2333
1971
|
const filePath = path.join(item.path, file.path);
|
|
2334
|
-
if (
|
|
1972
|
+
if (fs5.existsSync(filePath)) {
|
|
2335
1973
|
const backupPath = path.join(backupDir, file.path);
|
|
2336
|
-
await
|
|
1974
|
+
await fs5.promises.copyFile(filePath, backupPath);
|
|
2337
1975
|
}
|
|
2338
1976
|
}
|
|
2339
1977
|
log.muted(` Backed up ${definition.files.length} file(s) to .prism-backup/`);
|
|
@@ -2348,7 +1986,7 @@ async function updateItem(item, config, options) {
|
|
|
2348
1986
|
definition,
|
|
2349
1987
|
item.type === "block"
|
|
2350
1988
|
);
|
|
2351
|
-
await
|
|
1989
|
+
await fs5.promises.writeFile(filePath, content, "utf-8");
|
|
2352
1990
|
}
|
|
2353
1991
|
log.muted(` Updated ${definition.files.length} file(s) in ${path.relative(config.rootDir, item.path)}/`);
|
|
2354
1992
|
const lockfilePath = path.join(config.rootDir, "prism.lock.json");
|
|
@@ -2357,9 +1995,9 @@ async function updateItem(item, config, options) {
|
|
|
2357
1995
|
components: {},
|
|
2358
1996
|
blocks: {}
|
|
2359
1997
|
};
|
|
2360
|
-
if (
|
|
1998
|
+
if (fs5.existsSync(lockfilePath)) {
|
|
2361
1999
|
try {
|
|
2362
|
-
lockfile = JSON.parse(await
|
|
2000
|
+
lockfile = JSON.parse(await fs5.promises.readFile(lockfilePath, "utf-8"));
|
|
2363
2001
|
} catch {
|
|
2364
2002
|
}
|
|
2365
2003
|
}
|
|
@@ -2373,7 +2011,7 @@ async function updateItem(item, config, options) {
|
|
|
2373
2011
|
} else {
|
|
2374
2012
|
lockfile.components[item.name] = entry;
|
|
2375
2013
|
}
|
|
2376
|
-
await
|
|
2014
|
+
await fs5.promises.writeFile(lockfilePath, JSON.stringify(lockfile, null, 2), "utf-8");
|
|
2377
2015
|
}
|
|
2378
2016
|
|
|
2379
2017
|
// src/cli/commands/remove.ts
|
|
@@ -2431,7 +2069,7 @@ async function removeItem(item, config, options) {
|
|
|
2431
2069
|
const isBlock = item.startsWith("block:");
|
|
2432
2070
|
const name = isBlock ? item.replace("block:", "") : item;
|
|
2433
2071
|
const itemPath = isBlock ? getBlockPath(name, config) : getComponentPath(name, config);
|
|
2434
|
-
if (!
|
|
2072
|
+
if (!fs5.existsSync(itemPath)) {
|
|
2435
2073
|
return {
|
|
2436
2074
|
name: item,
|
|
2437
2075
|
success: false,
|
|
@@ -2439,7 +2077,7 @@ async function removeItem(item, config, options) {
|
|
|
2439
2077
|
};
|
|
2440
2078
|
}
|
|
2441
2079
|
try {
|
|
2442
|
-
await
|
|
2080
|
+
await fs5.promises.rm(itemPath, { recursive: true, force: true });
|
|
2443
2081
|
log.success(`Removed ${name} from ${path.relative(config.rootDir, itemPath)}/`);
|
|
2444
2082
|
await updateLockfile2(config.rootDir, name, isBlock);
|
|
2445
2083
|
return { name: item, success: true };
|
|
@@ -2453,17 +2091,17 @@ async function removeItem(item, config, options) {
|
|
|
2453
2091
|
}
|
|
2454
2092
|
async function updateLockfile2(rootDir, name, isBlock) {
|
|
2455
2093
|
const lockfilePath = path.join(rootDir, "prism.lock.json");
|
|
2456
|
-
if (!
|
|
2094
|
+
if (!fs5.existsSync(lockfilePath)) {
|
|
2457
2095
|
return;
|
|
2458
2096
|
}
|
|
2459
2097
|
try {
|
|
2460
|
-
const lockfile = JSON.parse(await
|
|
2098
|
+
const lockfile = JSON.parse(await fs5.promises.readFile(lockfilePath, "utf-8"));
|
|
2461
2099
|
if (isBlock) {
|
|
2462
2100
|
delete lockfile.blocks[name];
|
|
2463
2101
|
} else {
|
|
2464
2102
|
delete lockfile.components[name];
|
|
2465
2103
|
}
|
|
2466
|
-
await
|
|
2104
|
+
await fs5.promises.writeFile(lockfilePath, JSON.stringify(lockfile, null, 2) + "\n", "utf-8");
|
|
2467
2105
|
log.muted(` Updated prism.lock.json`);
|
|
2468
2106
|
} catch {
|
|
2469
2107
|
log.warning(" Could not update lockfile");
|
|
@@ -2529,7 +2167,7 @@ async function checkConfigFile(cwd) {
|
|
|
2529
2167
|
async function checkPackageJson(cwd) {
|
|
2530
2168
|
const results = [];
|
|
2531
2169
|
const pkgPath = path.join(cwd, "package.json");
|
|
2532
|
-
if (!
|
|
2170
|
+
if (!fs5.existsSync(pkgPath)) {
|
|
2533
2171
|
results.push({
|
|
2534
2172
|
name: "package.json",
|
|
2535
2173
|
status: "fail",
|
|
@@ -2538,7 +2176,7 @@ async function checkPackageJson(cwd) {
|
|
|
2538
2176
|
return results;
|
|
2539
2177
|
}
|
|
2540
2178
|
try {
|
|
2541
|
-
const pkg2 = JSON.parse(await
|
|
2179
|
+
const pkg2 = JSON.parse(await fs5.promises.readFile(pkgPath, "utf-8"));
|
|
2542
2180
|
const allDeps = { ...pkg2.dependencies, ...pkg2.devDependencies, ...pkg2.peerDependencies };
|
|
2543
2181
|
const requiredPeers = ["react", "react-dom", "@mui/material"];
|
|
2544
2182
|
for (const dep of requiredPeers) {
|
|
@@ -2591,7 +2229,7 @@ function checkDirectories(config) {
|
|
|
2591
2229
|
};
|
|
2592
2230
|
for (const [name, alias] of Object.entries(dirs)) {
|
|
2593
2231
|
const resolved = resolveAlias(alias, config);
|
|
2594
|
-
if (
|
|
2232
|
+
if (fs5.existsSync(resolved)) {
|
|
2595
2233
|
results.push({
|
|
2596
2234
|
name: `${name} directory`,
|
|
2597
2235
|
status: "pass",
|
|
@@ -2609,7 +2247,7 @@ function checkDirectories(config) {
|
|
|
2609
2247
|
}
|
|
2610
2248
|
async function checkTsConfig(cwd) {
|
|
2611
2249
|
const tsConfigPath = path.join(cwd, "tsconfig.json");
|
|
2612
|
-
if (!
|
|
2250
|
+
if (!fs5.existsSync(tsConfigPath)) {
|
|
2613
2251
|
return {
|
|
2614
2252
|
name: "TypeScript",
|
|
2615
2253
|
status: "warn",
|
|
@@ -2617,7 +2255,7 @@ async function checkTsConfig(cwd) {
|
|
|
2617
2255
|
};
|
|
2618
2256
|
}
|
|
2619
2257
|
try {
|
|
2620
|
-
const content = await
|
|
2258
|
+
const content = await fs5.promises.readFile(tsConfigPath, "utf-8");
|
|
2621
2259
|
const stripped = content.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
2622
2260
|
const tsConfig = JSON.parse(stripped);
|
|
2623
2261
|
const paths = tsConfig.compilerOptions?.paths || tsConfig.compilerOptions?.baseUrl;
|
|
@@ -2643,7 +2281,7 @@ async function checkTsConfig(cwd) {
|
|
|
2643
2281
|
}
|
|
2644
2282
|
async function checkLockfile(cwd) {
|
|
2645
2283
|
const lockfilePath = path.join(cwd, "prism.lock.json");
|
|
2646
|
-
if (!
|
|
2284
|
+
if (!fs5.existsSync(lockfilePath)) {
|
|
2647
2285
|
return {
|
|
2648
2286
|
name: "Lockfile",
|
|
2649
2287
|
status: "pass",
|
|
@@ -2651,7 +2289,7 @@ async function checkLockfile(cwd) {
|
|
|
2651
2289
|
};
|
|
2652
2290
|
}
|
|
2653
2291
|
try {
|
|
2654
|
-
const lockfile = JSON.parse(await
|
|
2292
|
+
const lockfile = JSON.parse(await fs5.promises.readFile(lockfilePath, "utf-8"));
|
|
2655
2293
|
const componentCount = Object.keys(lockfile.components || {}).length;
|
|
2656
2294
|
const blockCount = Object.keys(lockfile.blocks || {}).length;
|
|
2657
2295
|
return {
|