From f3ecf0d530b8ae2bcaf6884c5e43a0fb5a9fb305 Mon Sep 17 00:00:00 2001 From: Aidan Bleser Date: Mon, 6 Jan 2025 10:16:10 -0600 Subject: [PATCH] fixes #332 --- .changeset/odd-tables-clean.md | 5 + examples/registry/blocks/vue/Test.vue | 11 + examples/registry/blocks/vue/type.ts | 1 + examples/registry/jsrepo-manifest.json | 224 --------------------- packages/cli/package.json | 16 +- packages/cli/src/utils/language-support.ts | 9 +- 6 files changed, 27 insertions(+), 239 deletions(-) create mode 100644 .changeset/odd-tables-clean.md create mode 100644 examples/registry/blocks/vue/Test.vue create mode 100644 examples/registry/blocks/vue/type.ts delete mode 100644 examples/registry/jsrepo-manifest.json diff --git a/.changeset/odd-tables-clean.md b/.changeset/odd-tables-clean.md new file mode 100644 index 00000000..27276050 --- /dev/null +++ b/.changeset/odd-tables-clean.md @@ -0,0 +1,5 @@ +--- +"jsrepo": patch +--- + +Ensure vue compiler has `fs` access. diff --git a/examples/registry/blocks/vue/Test.vue b/examples/registry/blocks/vue/Test.vue new file mode 100644 index 00000000..a51e04c5 --- /dev/null +++ b/examples/registry/blocks/vue/Test.vue @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/examples/registry/blocks/vue/type.ts b/examples/registry/blocks/vue/type.ts new file mode 100644 index 00000000..eccce919 --- /dev/null +++ b/examples/registry/blocks/vue/type.ts @@ -0,0 +1 @@ +export type PropType = { value: string }; \ No newline at end of file diff --git a/examples/registry/jsrepo-manifest.json b/examples/registry/jsrepo-manifest.json deleted file mode 100644 index 10d0e4e2..00000000 --- a/examples/registry/jsrepo-manifest.json +++ /dev/null @@ -1,224 +0,0 @@ -[ - { - "name": "components", - "blocks": [ - { - "name": "button", - "directory": "src/components", - "category": "components", - "tests": false, - "subdirectory": false, - "list": true, - "files": [ - "button.svelte" - ], - "localDependencies": [ - "types/point" - ], - "_imports_": { - "../types/point": "{{types/point}}" - }, - "dependencies": [], - "devDependencies": [] - } - ] - }, - { - "name": "types", - "blocks": [ - { - "name": "index", - "directory": "src/types", - "category": "types", - "tests": false, - "subdirectory": false, - "list": true, - "files": [ - "index.ts" - ], - "localDependencies": [ - "types/point" - ], - "_imports_": { - "./point": "{{types/point}}" - }, - "dependencies": [], - "devDependencies": [] - }, - { - "name": "point", - "directory": "src/types", - "category": "types", - "tests": false, - "subdirectory": false, - "list": true, - "files": [ - "point.ts" - ], - "localDependencies": [], - "_imports_": {}, - "dependencies": [], - "devDependencies": [] - } - ] - }, - { - "name": "utils", - "blocks": [ - { - "name": "math", - "directory": "src/utils/math", - "category": "utils", - "tests": true, - "subdirectory": true, - "list": true, - "files": [ - "add.test.ts", - "add.ts", - "create-point.ts", - "format-answer.ts", - "index.ts", - "subtract.test.ts", - "subtract.ts" - ], - "localDependencies": [ - "types/point", - "utils/pretty-print" - ], - "dependencies": [], - "devDependencies": [], - "_imports_": { - "../../types/point": "{{types/point}}", - "../pretty-print": "{{utils/pretty-print}}" - } - }, - { - "name": "math-user", - "directory": "src/utils/math-user", - "category": "utils", - "tests": false, - "subdirectory": true, - "list": true, - "files": [ - "use.ts" - ], - "localDependencies": [ - "utils/math" - ], - "dependencies": [], - "devDependencies": [], - "_imports_": { - "$utils/math/add": "{{utils/math}}/add" - } - }, - { - "name": "pretty-print", - "directory": "src/utils/pretty-print", - "category": "utils", - "tests": false, - "subdirectory": true, - "list": true, - "files": [ - "index.ts", - "print.ts" - ], - "localDependencies": [ - "logging/logger" - ], - "dependencies": [ - "chalk@^5.3.0" - ], - "devDependencies": [], - "_imports_": { - "$logging/logger": "{{logging/logger}}" - } - } - ] - }, - { - "name": "angular", - "blocks": [ - { - "name": "button", - "directory": "blocks/angular/button", - "category": "angular", - "tests": false, - "subdirectory": true, - "list": true, - "files": [ - "button.html" - ], - "localDependencies": [ - "styles/test", - "scripts/test" - ], - "dependencies": [], - "devDependencies": [], - "_imports_": { - "../../styles/test.scss": "{{styles/test}}.scss", - "../../scripts/test.js": "{{scripts/test}}.js" - } - } - ] - }, - { - "name": "logging", - "blocks": [ - { - "name": "logger", - "directory": "blocks/logging", - "category": "logging", - "tests": false, - "subdirectory": false, - "list": true, - "files": [ - "logger.ts" - ], - "localDependencies": [], - "_imports_": {}, - "dependencies": [], - "devDependencies": [] - } - ] - }, - { - "name": "scripts", - "blocks": [ - { - "name": "test", - "directory": "blocks/scripts", - "category": "scripts", - "tests": false, - "subdirectory": false, - "list": true, - "files": [ - "test.js" - ], - "localDependencies": [], - "_imports_": {}, - "dependencies": [], - "devDependencies": [] - } - ] - }, - { - "name": "styles", - "blocks": [ - { - "name": "test", - "directory": "blocks/styles", - "category": "styles", - "tests": false, - "subdirectory": false, - "list": true, - "files": [ - "test.scss" - ], - "localDependencies": [], - "_imports_": {}, - "dependencies": [], - "devDependencies": [] - } - ] - } -] \ No newline at end of file diff --git a/packages/cli/package.json b/packages/cli/package.json index 46ebf18c..b16063e0 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -15,24 +15,12 @@ "bugs": { "url": "https://github.com/ieedan/jsrepo/issues" }, - "keywords": [ - "repo", - "cli", - "svelte", - "vue", - "typescript", - "javascript", - "shadcn", - "registry" - ], + "keywords": ["repo", "cli", "svelte", "vue", "typescript", "javascript", "shadcn", "registry"], "type": "module", "exports": "./dist/index.js", "bin": "./dist/index.js", "main": "./dist/index.js", - "files": [ - "./schemas/**/*", - "dist" - ], + "files": ["./schemas/**/*", "dist"], "scripts": { "start": "tsup --silent && node ./dist/index.js", "build": "tsup", diff --git a/packages/cli/src/utils/language-support.ts b/packages/cli/src/utils/language-support.ts index ca4abc41..1887b3f6 100644 --- a/packages/cli/src/utils/language-support.ts +++ b/packages/cli/src/utils/language-support.ts @@ -390,7 +390,14 @@ const vue: Lang = { let compiled: v.SFCScriptBlock; try { - compiled = v.compileScript(parsed.descriptor, { id: 'shut-it' }); // you need this id to remove a warning + compiled = v.compileScript(parsed.descriptor, { + id: 'shut-it', + fs: { + fileExists: fs.existsSync, + readFile: (file) => fs.readFileSync(file).toString(), + realpath: fs.realpathSync, + }, + }); // you need this id to remove a warning } catch (err) { return Err(`Compile error: ${err}`); }