@awsless/ts-file-cache 0.0.8 → 0.0.9
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.cjs +6 -13
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -13
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -135,7 +135,7 @@ var generateRecursiveFileHashes = async (workspace, file, source, allowedExtensi
|
|
|
135
135
|
if (dependency.type === "package") {
|
|
136
136
|
hashes.set(file, Buffer.from(`${file}:${dependency.version}`, "utf8"));
|
|
137
137
|
} else {
|
|
138
|
-
const localPackage = workspace.packages
|
|
138
|
+
const localPackage = workspace.packages[file];
|
|
139
139
|
if (!localPackage) {
|
|
140
140
|
throw new Error(`Can't find the local workspace package for: ${file}`);
|
|
141
141
|
}
|
|
@@ -155,16 +155,14 @@ var generateRecursiveFileHashes = async (workspace, file, source, allowedExtensi
|
|
|
155
155
|
if (import_node_module.builtinModules.includes(file.replace(/^node\:/, ""))) {
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
|
-
throw new Error(`Can't find the dependency version for: ${file}`);
|
|
158
|
+
throw new Error(`Can't find the dependency version for: ${file} inside the source: ${source}`);
|
|
159
159
|
};
|
|
160
160
|
var mergeHashes = (hashes) => {
|
|
161
161
|
const merge = Buffer.concat(Array.from(hashes.values()).sort());
|
|
162
162
|
return (0, import_crypto.createHash)("sha1").update(merge).digest("hex");
|
|
163
163
|
};
|
|
164
164
|
var findDependency = (workspace, module2, source) => {
|
|
165
|
-
const pkg = workspace.packages.find((
|
|
166
|
-
return source.startsWith(pkg2.path);
|
|
167
|
-
});
|
|
165
|
+
const pkg = Object.values(workspace.packages).filter((p) => source.startsWith(p.path)).sort((a, b) => b.path.split("/").length - a.path.split("/").length).find((p) => p.dependencies[module2]);
|
|
168
166
|
if (!pkg) {
|
|
169
167
|
return;
|
|
170
168
|
}
|
|
@@ -181,7 +179,7 @@ var import_yaml = require("yaml");
|
|
|
181
179
|
var pnpm = async (search) => {
|
|
182
180
|
const [cwd, lockFile] = await findLockFile(search);
|
|
183
181
|
const data = (0, import_yaml.parse)(lockFile);
|
|
184
|
-
const packages =
|
|
182
|
+
const packages = {};
|
|
185
183
|
await Promise.all(
|
|
186
184
|
Object.entries(data.importers).map(async ([path, importee]) => {
|
|
187
185
|
const deps = { ...importee.devDependencies, ...importee.dependencies };
|
|
@@ -202,12 +200,12 @@ var pnpm = async (search) => {
|
|
|
202
200
|
}
|
|
203
201
|
}
|
|
204
202
|
const entry = packageData.module ?? packageData.main;
|
|
205
|
-
packages.
|
|
203
|
+
packages[packageData.name] = {
|
|
206
204
|
name: packageData.name,
|
|
207
205
|
path: (0, import_path4.join)(cwd, path),
|
|
208
206
|
main: entry ? (0, import_path4.join)(cwd, path, entry) : void 0,
|
|
209
207
|
dependencies
|
|
210
|
-
}
|
|
208
|
+
};
|
|
211
209
|
})
|
|
212
210
|
);
|
|
213
211
|
return {
|
|
@@ -240,11 +238,6 @@ var fileExist = async (file) => {
|
|
|
240
238
|
// src/index.ts
|
|
241
239
|
var loadWorkspace = async (search) => {
|
|
242
240
|
const { cwd, packages } = await pnpm(toAbsolute(search));
|
|
243
|
-
const sizes = {};
|
|
244
|
-
packages.forEach((pkg) => {
|
|
245
|
-
sizes[pkg.name] = pkg.path.split("/").length;
|
|
246
|
-
});
|
|
247
|
-
packages.sort((a, b) => sizes[b.name] - sizes[a.name]);
|
|
248
241
|
return {
|
|
249
242
|
cwd,
|
|
250
243
|
packages
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -109,7 +109,7 @@ var generateRecursiveFileHashes = async (workspace, file, source, allowedExtensi
|
|
|
109
109
|
if (dependency.type === "package") {
|
|
110
110
|
hashes.set(file, Buffer.from(`${file}:${dependency.version}`, "utf8"));
|
|
111
111
|
} else {
|
|
112
|
-
const localPackage = workspace.packages
|
|
112
|
+
const localPackage = workspace.packages[file];
|
|
113
113
|
if (!localPackage) {
|
|
114
114
|
throw new Error(`Can't find the local workspace package for: ${file}`);
|
|
115
115
|
}
|
|
@@ -129,16 +129,14 @@ var generateRecursiveFileHashes = async (workspace, file, source, allowedExtensi
|
|
|
129
129
|
if (builtinModules.includes(file.replace(/^node\:/, ""))) {
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
|
-
throw new Error(`Can't find the dependency version for: ${file}`);
|
|
132
|
+
throw new Error(`Can't find the dependency version for: ${file} inside the source: ${source}`);
|
|
133
133
|
};
|
|
134
134
|
var mergeHashes = (hashes) => {
|
|
135
135
|
const merge = Buffer.concat(Array.from(hashes.values()).sort());
|
|
136
136
|
return createHash("sha1").update(merge).digest("hex");
|
|
137
137
|
};
|
|
138
138
|
var findDependency = (workspace, module, source) => {
|
|
139
|
-
const pkg = workspace.packages.find((
|
|
140
|
-
return source.startsWith(pkg2.path);
|
|
141
|
-
});
|
|
139
|
+
const pkg = Object.values(workspace.packages).filter((p) => source.startsWith(p.path)).sort((a, b) => b.path.split("/").length - a.path.split("/").length).find((p) => p.dependencies[module]);
|
|
142
140
|
if (!pkg) {
|
|
143
141
|
return;
|
|
144
142
|
}
|
|
@@ -155,7 +153,7 @@ import { parse as parse2 } from "yaml";
|
|
|
155
153
|
var pnpm = async (search) => {
|
|
156
154
|
const [cwd, lockFile] = await findLockFile(search);
|
|
157
155
|
const data = parse2(lockFile);
|
|
158
|
-
const packages =
|
|
156
|
+
const packages = {};
|
|
159
157
|
await Promise.all(
|
|
160
158
|
Object.entries(data.importers).map(async ([path, importee]) => {
|
|
161
159
|
const deps = { ...importee.devDependencies, ...importee.dependencies };
|
|
@@ -176,12 +174,12 @@ var pnpm = async (search) => {
|
|
|
176
174
|
}
|
|
177
175
|
}
|
|
178
176
|
const entry = packageData.module ?? packageData.main;
|
|
179
|
-
packages.
|
|
177
|
+
packages[packageData.name] = {
|
|
180
178
|
name: packageData.name,
|
|
181
179
|
path: join2(cwd, path),
|
|
182
180
|
main: entry ? join2(cwd, path, entry) : void 0,
|
|
183
181
|
dependencies
|
|
184
|
-
}
|
|
182
|
+
};
|
|
185
183
|
})
|
|
186
184
|
);
|
|
187
185
|
return {
|
|
@@ -214,11 +212,6 @@ var fileExist = async (file) => {
|
|
|
214
212
|
// src/index.ts
|
|
215
213
|
var loadWorkspace = async (search) => {
|
|
216
214
|
const { cwd, packages } = await pnpm(toAbsolute(search));
|
|
217
|
-
const sizes = {};
|
|
218
|
-
packages.forEach((pkg) => {
|
|
219
|
-
sizes[pkg.name] = pkg.path.split("/").length;
|
|
220
|
-
});
|
|
221
|
-
packages.sort((a, b) => sizes[b.name] - sizes[a.name]);
|
|
222
215
|
return {
|
|
223
216
|
cwd,
|
|
224
217
|
packages
|