jsrepo 1.12.0 → 1.12.2
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/dist/index.js +13 -16
- package/package.json +1 -1
- package/src/commands/update.ts +1 -1
- package/src/utils/build.ts +0 -2
- package/src/utils/language-support.ts +12 -13
package/dist/index.js
CHANGED
|
@@ -802,7 +802,7 @@ var parsePackageName = (input) => {
|
|
|
802
802
|
// src/utils/language-support.ts
|
|
803
803
|
var typescript = {
|
|
804
804
|
matches: (fileName) => fileName.endsWith(".ts") || fileName.endsWith(".js") || fileName.endsWith(".tsx") || fileName.endsWith(".jsx"),
|
|
805
|
-
resolveDependencies: ({ filePath, isSubDir, excludeDeps
|
|
805
|
+
resolveDependencies: ({ filePath, isSubDir, excludeDeps }) => {
|
|
806
806
|
const project = new Project();
|
|
807
807
|
const blockFile = project.addSourceFileAtPath(filePath);
|
|
808
808
|
const imports = blockFile.getImportDeclarations();
|
|
@@ -812,9 +812,9 @@ var typescript = {
|
|
|
812
812
|
const localDeps = /* @__PURE__ */ new Set();
|
|
813
813
|
for (const relativeImport of relativeImports) {
|
|
814
814
|
const mod = relativeImport.getModuleSpecifierValue();
|
|
815
|
-
const localDep = resolveLocalImport(mod, isSubDir, { filePath
|
|
815
|
+
const localDep = resolveLocalImport(mod, isSubDir, { filePath });
|
|
816
816
|
if (localDep.isErr()) return Err(localDep.unwrapErr());
|
|
817
|
-
if (localDep) localDeps.add(localDep.unwrap());
|
|
817
|
+
if (localDep.unwrap()) localDeps.add(localDep.unwrap());
|
|
818
818
|
}
|
|
819
819
|
const deps = imports.filter((declaration) => !declaration.getModuleSpecifierValue().startsWith(".")).map((declaration) => declaration.getModuleSpecifierValue());
|
|
820
820
|
const { devDependencies, dependencies } = resolveRemoteDeps(
|
|
@@ -847,7 +847,7 @@ ${join(get(content), { prefix: () => " " })}
|
|
|
847
847
|
};
|
|
848
848
|
var svelte = {
|
|
849
849
|
matches: (fileName) => fileName.endsWith(".svelte"),
|
|
850
|
-
resolveDependencies: ({ filePath, isSubDir, excludeDeps
|
|
850
|
+
resolveDependencies: ({ filePath, isSubDir, excludeDeps }) => {
|
|
851
851
|
const sourceCode = fs2.readFileSync(filePath).toString();
|
|
852
852
|
const root = sv.parse(sourceCode, { modern: true, filename: filePath });
|
|
853
853
|
if (!root.instance) return Ok({ dependencies: [], devDependencies: [], local: [] });
|
|
@@ -859,11 +859,10 @@ var svelte = {
|
|
|
859
859
|
if (typeof node.source.value === "string") {
|
|
860
860
|
if (node.source.value.startsWith(".")) {
|
|
861
861
|
const localDep = resolveLocalImport(node.source.value, isSubDir, {
|
|
862
|
-
filePath
|
|
863
|
-
cwd
|
|
862
|
+
filePath
|
|
864
863
|
});
|
|
865
864
|
if (localDep.isErr()) return Err(localDep.unwrapErr());
|
|
866
|
-
if (localDep) localDeps.add(localDep.unwrap());
|
|
865
|
+
if (localDep.unwrap()) localDeps.add(localDep.unwrap());
|
|
867
866
|
} else {
|
|
868
867
|
deps.add(node.source.value);
|
|
869
868
|
}
|
|
@@ -894,7 +893,7 @@ ${join(get(content), { prefix: () => " " })}
|
|
|
894
893
|
};
|
|
895
894
|
var vue = {
|
|
896
895
|
matches: (fileName) => fileName.endsWith(".vue"),
|
|
897
|
-
resolveDependencies: ({ filePath, isSubDir, excludeDeps
|
|
896
|
+
resolveDependencies: ({ filePath, isSubDir, excludeDeps }) => {
|
|
898
897
|
const sourceCode = fs2.readFileSync(filePath).toString();
|
|
899
898
|
const parsed = v.parse(sourceCode, { filename: filePath });
|
|
900
899
|
if (!parsed.descriptor.script?.content && !parsed.descriptor.scriptSetup?.content)
|
|
@@ -912,11 +911,10 @@ var vue = {
|
|
|
912
911
|
for (const imp of imports) {
|
|
913
912
|
if (imp.source.startsWith(".")) {
|
|
914
913
|
const localDep = resolveLocalImport(imp.source, isSubDir, {
|
|
915
|
-
filePath
|
|
916
|
-
cwd
|
|
914
|
+
filePath
|
|
917
915
|
});
|
|
918
916
|
if (localDep.isErr()) return Err(localDep.unwrapErr());
|
|
919
|
-
if (localDep) localDeps.add(localDep.unwrap());
|
|
917
|
+
if (localDep.unwrap()) localDeps.add(localDep.unwrap());
|
|
920
918
|
} else {
|
|
921
919
|
deps.add(imp.source);
|
|
922
920
|
}
|
|
@@ -954,10 +952,11 @@ var yaml = {
|
|
|
954
952
|
return code;
|
|
955
953
|
}
|
|
956
954
|
};
|
|
957
|
-
var resolveLocalImport = (mod, isSubDir, { filePath
|
|
955
|
+
var resolveLocalImport = (mod, isSubDir, { filePath }) => {
|
|
956
|
+
if (isSubDir && (mod.startsWith("./") || mod === ".")) return Ok(void 0);
|
|
958
957
|
const categoryDir = isSubDir ? path2.join(filePath, "../../") : path2.join(filePath, "../");
|
|
959
958
|
const modPath = path2.join(path2.join(filePath, "../"), mod);
|
|
960
|
-
const fullDir = path2.join(
|
|
959
|
+
const fullDir = path2.join(categoryDir, "../");
|
|
961
960
|
if (modPath.startsWith(fullDir)) {
|
|
962
961
|
let [category, block] = modPath.slice(fullDir.length).split("/");
|
|
963
962
|
if (block.includes(".")) {
|
|
@@ -1091,7 +1090,6 @@ var buildBlocksDirectory = (blocksPath, { cwd, excludeDeps, includeBlocks, inclu
|
|
|
1091
1090
|
);
|
|
1092
1091
|
const { dependencies, devDependencies, local } = lang.resolveDependencies({
|
|
1093
1092
|
filePath: blockDir,
|
|
1094
|
-
category: categoryName,
|
|
1095
1093
|
isSubDir: false,
|
|
1096
1094
|
excludeDeps,
|
|
1097
1095
|
cwd
|
|
@@ -1164,7 +1162,6 @@ var buildBlocksDirectory = (blocksPath, { cwd, excludeDeps, includeBlocks, inclu
|
|
|
1164
1162
|
}
|
|
1165
1163
|
const { local, dependencies, devDependencies } = lang.resolveDependencies({
|
|
1166
1164
|
filePath: path3.join(blockDir, f),
|
|
1167
|
-
category: categoryName,
|
|
1168
1165
|
isSubDir: true,
|
|
1169
1166
|
excludeDeps,
|
|
1170
1167
|
cwd
|
|
@@ -3298,7 +3295,7 @@ ${prefix?.() ?? ""}
|
|
|
3298
3295
|
}
|
|
3299
3296
|
});
|
|
3300
3297
|
process.stdout.write(formattedDiff);
|
|
3301
|
-
if (changes.length > 1) {
|
|
3298
|
+
if (changes.length > 1 || localContent === "") {
|
|
3302
3299
|
const confirmResult = await confirm6({
|
|
3303
3300
|
message: "Accept changes?",
|
|
3304
3301
|
initialValue: true
|
package/package.json
CHANGED
package/src/commands/update.ts
CHANGED
|
@@ -290,7 +290,7 @@ const _update = async (blockNames: string[], options: Options) => {
|
|
|
290
290
|
process.stdout.write(formattedDiff);
|
|
291
291
|
|
|
292
292
|
// if there are no changes then don't ask
|
|
293
|
-
if (changes.length > 1) {
|
|
293
|
+
if (changes.length > 1 || localContent === '') {
|
|
294
294
|
const confirmResult = await confirm({
|
|
295
295
|
message: 'Accept changes?',
|
|
296
296
|
initialValue: true,
|
package/src/utils/build.ts
CHANGED
|
@@ -128,7 +128,6 @@ const buildBlocksDirectory = (
|
|
|
128
128
|
const { dependencies, devDependencies, local } = lang
|
|
129
129
|
.resolveDependencies({
|
|
130
130
|
filePath: blockDir,
|
|
131
|
-
category: categoryName,
|
|
132
131
|
isSubDir: false,
|
|
133
132
|
excludeDeps,
|
|
134
133
|
cwd,
|
|
@@ -222,7 +221,6 @@ const buildBlocksDirectory = (
|
|
|
222
221
|
const { local, dependencies, devDependencies } = lang
|
|
223
222
|
.resolveDependencies({
|
|
224
223
|
filePath: path.join(blockDir, f),
|
|
225
|
-
category: categoryName,
|
|
226
224
|
isSubDir: true,
|
|
227
225
|
excludeDeps,
|
|
228
226
|
cwd,
|
|
@@ -25,7 +25,6 @@ export type ResolvedDependencies = {
|
|
|
25
25
|
|
|
26
26
|
export type ResolveDependencyOptions = {
|
|
27
27
|
filePath: string;
|
|
28
|
-
category: string;
|
|
29
28
|
isSubDir: boolean;
|
|
30
29
|
excludeDeps: string[];
|
|
31
30
|
cwd: string;
|
|
@@ -55,7 +54,7 @@ const typescript: Lang = {
|
|
|
55
54
|
fileName.endsWith('.js') ||
|
|
56
55
|
fileName.endsWith('.tsx') ||
|
|
57
56
|
fileName.endsWith('.jsx'),
|
|
58
|
-
resolveDependencies: ({ filePath, isSubDir, excludeDeps
|
|
57
|
+
resolveDependencies: ({ filePath, isSubDir, excludeDeps }) => {
|
|
59
58
|
const project = new Project();
|
|
60
59
|
|
|
61
60
|
const blockFile = project.addSourceFileAtPath(filePath);
|
|
@@ -71,11 +70,11 @@ const typescript: Lang = {
|
|
|
71
70
|
for (const relativeImport of relativeImports) {
|
|
72
71
|
const mod = relativeImport.getModuleSpecifierValue();
|
|
73
72
|
|
|
74
|
-
const localDep = resolveLocalImport(mod, isSubDir, { filePath
|
|
73
|
+
const localDep = resolveLocalImport(mod, isSubDir, { filePath });
|
|
75
74
|
|
|
76
75
|
if (localDep.isErr()) return Err(localDep.unwrapErr());
|
|
77
76
|
|
|
78
|
-
if (localDep) localDeps.add(localDep.unwrap());
|
|
77
|
+
if (localDep.unwrap()) localDeps.add(localDep.unwrap()!);
|
|
79
78
|
}
|
|
80
79
|
|
|
81
80
|
const deps = imports
|
|
@@ -116,7 +115,7 @@ const typescript: Lang = {
|
|
|
116
115
|
|
|
117
116
|
const svelte: Lang = {
|
|
118
117
|
matches: (fileName) => fileName.endsWith('.svelte'),
|
|
119
|
-
resolveDependencies: ({ filePath, isSubDir, excludeDeps
|
|
118
|
+
resolveDependencies: ({ filePath, isSubDir, excludeDeps }) => {
|
|
120
119
|
const sourceCode = fs.readFileSync(filePath).toString();
|
|
121
120
|
|
|
122
121
|
const root = sv.parse(sourceCode, { modern: true, filename: filePath });
|
|
@@ -135,12 +134,11 @@ const svelte: Lang = {
|
|
|
135
134
|
if (node.source.value.startsWith('.')) {
|
|
136
135
|
const localDep = resolveLocalImport(node.source.value, isSubDir, {
|
|
137
136
|
filePath,
|
|
138
|
-
cwd,
|
|
139
137
|
});
|
|
140
138
|
|
|
141
139
|
if (localDep.isErr()) return Err(localDep.unwrapErr());
|
|
142
140
|
|
|
143
|
-
if (localDep) localDeps.add(localDep.unwrap());
|
|
141
|
+
if (localDep.unwrap()) localDeps.add(localDep.unwrap()!);
|
|
144
142
|
} else {
|
|
145
143
|
deps.add(node.source.value);
|
|
146
144
|
}
|
|
@@ -179,7 +177,7 @@ const svelte: Lang = {
|
|
|
179
177
|
|
|
180
178
|
const vue: Lang = {
|
|
181
179
|
matches: (fileName) => fileName.endsWith('.vue'),
|
|
182
|
-
resolveDependencies: ({ filePath, isSubDir, excludeDeps
|
|
180
|
+
resolveDependencies: ({ filePath, isSubDir, excludeDeps }) => {
|
|
183
181
|
const sourceCode = fs.readFileSync(filePath).toString();
|
|
184
182
|
|
|
185
183
|
const parsed = v.parse(sourceCode, { filename: filePath });
|
|
@@ -205,12 +203,11 @@ const vue: Lang = {
|
|
|
205
203
|
if (imp.source.startsWith('.')) {
|
|
206
204
|
const localDep = resolveLocalImport(imp.source, isSubDir, {
|
|
207
205
|
filePath,
|
|
208
|
-
cwd,
|
|
209
206
|
});
|
|
210
207
|
|
|
211
208
|
if (localDep.isErr()) return Err(localDep.unwrapErr());
|
|
212
209
|
|
|
213
|
-
if (localDep) localDeps.add(localDep.unwrap());
|
|
210
|
+
if (localDep.unwrap()) localDeps.add(localDep.unwrap()!);
|
|
214
211
|
} else {
|
|
215
212
|
deps.add(imp.source);
|
|
216
213
|
}
|
|
@@ -258,8 +255,10 @@ const yaml: Lang = {
|
|
|
258
255
|
const resolveLocalImport = (
|
|
259
256
|
mod: string,
|
|
260
257
|
isSubDir: boolean,
|
|
261
|
-
{ filePath
|
|
262
|
-
): Result<string, string> => {
|
|
258
|
+
{ filePath }: { filePath: string }
|
|
259
|
+
): Result<string | undefined, string> => {
|
|
260
|
+
if (isSubDir && (mod.startsWith('./') || mod === '.')) return Ok(undefined);
|
|
261
|
+
|
|
263
262
|
// get the path to the current category
|
|
264
263
|
const categoryDir = isSubDir ? path.join(filePath, '../../') : path.join(filePath, '../');
|
|
265
264
|
|
|
@@ -267,7 +266,7 @@ const resolveLocalImport = (
|
|
|
267
266
|
const modPath = path.join(path.join(filePath, '../'), mod);
|
|
268
267
|
|
|
269
268
|
// get the full path to the current category
|
|
270
|
-
const fullDir = path.join(
|
|
269
|
+
const fullDir = path.join(categoryDir, '../');
|
|
271
270
|
|
|
272
271
|
// mod paths that reference outside of the current blocks directory are invalid
|
|
273
272
|
if (modPath.startsWith(fullDir)) {
|