@wraps.dev/cli 2.10.5 → 2.10.6
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/cli.js
CHANGED
|
@@ -19784,6 +19784,8 @@ async function templatesPush(options) {
|
|
|
19784
19784
|
}
|
|
19785
19785
|
const lockfilePath = join11(wrapsDir, ".wraps", "lockfile.json");
|
|
19786
19786
|
const lockfile = await loadLockfile(lockfilePath);
|
|
19787
|
+
const token = await resolveTokenAsync({ token: options.token });
|
|
19788
|
+
const remoteTemplateSlugs = await fetchRemoteTemplateSlugs(token, progress);
|
|
19787
19789
|
const compiled = [];
|
|
19788
19790
|
const unchanged = [];
|
|
19789
19791
|
const compileErrors = [];
|
|
@@ -19792,7 +19794,9 @@ async function templatesPush(options) {
|
|
|
19792
19794
|
const filePath = join11(templatesDir, file);
|
|
19793
19795
|
const source = await readFile4(filePath, "utf-8");
|
|
19794
19796
|
const sourceHash = sha256(source);
|
|
19795
|
-
|
|
19797
|
+
const localHashMatches = lockfile.templates[slug]?.localHash === sourceHash;
|
|
19798
|
+
const existsRemotely = remoteTemplateSlugs === null || remoteTemplateSlugs.has(slug);
|
|
19799
|
+
if (!options.force && localHashMatches && existsRemotely) {
|
|
19796
19800
|
unchanged.push(slug);
|
|
19797
19801
|
continue;
|
|
19798
19802
|
}
|
|
@@ -19868,7 +19872,6 @@ async function templatesPush(options) {
|
|
|
19868
19872
|
return;
|
|
19869
19873
|
}
|
|
19870
19874
|
await pushToSES(compiled, progress);
|
|
19871
|
-
const token = await resolveTokenAsync({ token: options.token });
|
|
19872
19875
|
const apiResults = await pushToAPI(compiled, token, config2.org, progress, options.force);
|
|
19873
19876
|
for (const t of compiled) {
|
|
19874
19877
|
const apiResult = apiResults.find((r) => r.slug === t.slug);
|
|
@@ -20066,6 +20069,29 @@ async function pushToSES(templates, progress) {
|
|
|
20066
20069
|
}
|
|
20067
20070
|
return results;
|
|
20068
20071
|
}
|
|
20072
|
+
async function fetchRemoteTemplateSlugs(token, progress) {
|
|
20073
|
+
if (!token) {
|
|
20074
|
+
return null;
|
|
20075
|
+
}
|
|
20076
|
+
const apiBase = process.env.WRAPS_API_URL || "https://api.wraps.dev";
|
|
20077
|
+
try {
|
|
20078
|
+
const resp = await fetch(`${apiBase}/v1/templates/pull`, {
|
|
20079
|
+
method: "GET",
|
|
20080
|
+
headers: {
|
|
20081
|
+
Authorization: `Bearer ${token}`
|
|
20082
|
+
}
|
|
20083
|
+
});
|
|
20084
|
+
if (!resp.ok) {
|
|
20085
|
+
progress.info("Could not check remote templates \u2014 using local change detection only");
|
|
20086
|
+
return null;
|
|
20087
|
+
}
|
|
20088
|
+
const data = await resp.json();
|
|
20089
|
+
return new Set(data.templates.map((t) => t.slug));
|
|
20090
|
+
} catch {
|
|
20091
|
+
progress.info("Could not check remote templates \u2014 using local change detection only");
|
|
20092
|
+
return null;
|
|
20093
|
+
}
|
|
20094
|
+
}
|
|
20069
20095
|
async function pushToAPI(templates, token, _org, progress, force) {
|
|
20070
20096
|
if (!token) {
|
|
20071
20097
|
progress.info(
|