create-ampless 1.0.0-alpha.81 → 1.0.0-alpha.82
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 +29 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1938,6 +1938,9 @@ function isThemeDirName(name) {
|
|
|
1938
1938
|
}
|
|
1939
1939
|
return true;
|
|
1940
1940
|
}
|
|
1941
|
+
function isQuarantinedThemeName(name) {
|
|
1942
|
+
return !isThemeDirName(name);
|
|
1943
|
+
}
|
|
1941
1944
|
async function listShippedThemes(templatesRoot) {
|
|
1942
1945
|
if (!existsSync5(templatesRoot)) return [];
|
|
1943
1946
|
const entries = await readdir3(templatesRoot, { withFileTypes: true });
|
|
@@ -1969,6 +1972,16 @@ async function syncThemes(destDir, templatesRoot) {
|
|
|
1969
1972
|
const shipped = await listShippedThemes(templatesRoot);
|
|
1970
1973
|
const themesDir = join3(destDir, "themes");
|
|
1971
1974
|
await mkdir2(themesDir, { recursive: true });
|
|
1975
|
+
const quarantined = [];
|
|
1976
|
+
if (existsSync5(themesDir)) {
|
|
1977
|
+
const present = await readdir3(themesDir, { withFileTypes: true });
|
|
1978
|
+
for (const entry of present) {
|
|
1979
|
+
if (!entry.isDirectory()) continue;
|
|
1980
|
+
if (!isQuarantinedThemeName(entry.name)) continue;
|
|
1981
|
+
await rm2(join3(themesDir, entry.name), { recursive: true, force: true });
|
|
1982
|
+
quarantined.push(entry.name);
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1972
1985
|
for (const name of shipped) {
|
|
1973
1986
|
const src = join3(templatesRoot, name);
|
|
1974
1987
|
const dst = join3(themesDir, name);
|
|
@@ -1982,10 +1995,12 @@ async function syncThemes(destDir, templatesRoot) {
|
|
|
1982
1995
|
}
|
|
1983
1996
|
const installed = await discoverInstalledThemes(destDir);
|
|
1984
1997
|
const shippedSet = new Set(shipped);
|
|
1985
|
-
const preserved = installed.filter(
|
|
1998
|
+
const preserved = installed.filter(
|
|
1999
|
+
(t) => !shippedSet.has(t) && !isQuarantinedThemeName(t)
|
|
2000
|
+
);
|
|
1986
2001
|
const all = [...shipped, ...preserved];
|
|
1987
2002
|
await writeFile3(join3(destDir, "themes-registry.ts"), buildRegistry(all), "utf-8");
|
|
1988
|
-
return { synced: shipped, preserved };
|
|
2003
|
+
return { synced: shipped, preserved, quarantined };
|
|
1989
2004
|
}
|
|
1990
2005
|
async function walkDir(dir, base, out) {
|
|
1991
2006
|
const entries = await readdir3(dir, { withFileTypes: true });
|
|
@@ -2114,7 +2129,10 @@ async function runUpgradeIn(destDir, sharedDir, opts = {}) {
|
|
|
2114
2129
|
const seedSkipped = classification.seed.filter((r) => existsSync5(join3(destDir, r)));
|
|
2115
2130
|
const shippedThemes = themeSyncEnabled ? await listShippedThemes(templatesRoot) : [];
|
|
2116
2131
|
const existingThemes = themeSyncEnabled ? await discoverInstalledThemes(destDir) : [];
|
|
2117
|
-
const
|
|
2132
|
+
const quarantinedThemesPreview = existingThemes.filter(isQuarantinedThemeName);
|
|
2133
|
+
const preservedThemes = existingThemes.filter(
|
|
2134
|
+
(t) => !shippedThemes.includes(t) && !isQuarantinedThemeName(t)
|
|
2135
|
+
);
|
|
2118
2136
|
const obsoleteFiles = await findObsoleteFiles(destDir, sharedDir);
|
|
2119
2137
|
log3.info(
|
|
2120
2138
|
`replace: ${pc3.green(`${replaceNew.length} added`)} / ${pc3.yellow(`${replaceUpdate.length} updated`)}`
|
|
@@ -2129,6 +2147,11 @@ async function runUpgradeIn(destDir, sharedDir, opts = {}) {
|
|
|
2129
2147
|
log3.info(
|
|
2130
2148
|
`themes: ${pc3.cyan(`${shippedThemes.length} default themes synced`)} / ${pc3.dim(`${preservedThemes.length} custom (my-*) themes preserved`)}`
|
|
2131
2149
|
);
|
|
2150
|
+
if (quarantinedThemesPreview.length > 0) {
|
|
2151
|
+
log3.info(
|
|
2152
|
+
`recover: ${pc3.yellow(`${quarantinedThemesPreview.length} bogus theme dir(s) removed`)} (${quarantinedThemesPreview.join(", ")} \u2014 scaffold templates leaked in by an earlier buggy create-ampless@alpha)`
|
|
2153
|
+
);
|
|
2154
|
+
}
|
|
2132
2155
|
}
|
|
2133
2156
|
if (obsoleteFiles.length > 0) {
|
|
2134
2157
|
log3.info(`cleanup: ${pc3.yellow(`${obsoleteFiles.length} removed`)} (files under ampless-managed app/ paths that no longer exist in the template)`);
|
|
@@ -2142,6 +2165,7 @@ async function runUpgradeIn(destDir, sharedDir, opts = {}) {
|
|
|
2142
2165
|
protected: classification.protected,
|
|
2143
2166
|
themesSynced: shippedThemes,
|
|
2144
2167
|
themesPreserved: preservedThemes,
|
|
2168
|
+
themesQuarantined: quarantinedThemesPreview,
|
|
2145
2169
|
packageJsonMerged: false,
|
|
2146
2170
|
obsoleteRemoved: obsoleteFiles
|
|
2147
2171
|
};
|
|
@@ -2156,7 +2180,7 @@ async function runUpgradeIn(destDir, sharedDir, opts = {}) {
|
|
|
2156
2180
|
const dst = join3(destDir, rel);
|
|
2157
2181
|
await copyWithSubstitution(src, dst, vars);
|
|
2158
2182
|
}
|
|
2159
|
-
const themeResult = themeSyncEnabled ? await syncThemes(destDir, templatesRoot) : { synced: [], preserved: [] };
|
|
2183
|
+
const themeResult = themeSyncEnabled ? await syncThemes(destDir, templatesRoot) : { synced: [], preserved: [], quarantined: [] };
|
|
2160
2184
|
await removeObsoleteFiles(destDir, obsoleteFiles);
|
|
2161
2185
|
const templatePkgRaw = await readFile3(join3(sharedDir, "package.json"), "utf-8");
|
|
2162
2186
|
const templatePkg = JSON.parse(templatePkgRaw);
|
|
@@ -2197,6 +2221,7 @@ async function runUpgradeIn(destDir, sharedDir, opts = {}) {
|
|
|
2197
2221
|
protected: classification.protected,
|
|
2198
2222
|
themesSynced: themeResult.synced,
|
|
2199
2223
|
themesPreserved: themeResult.preserved,
|
|
2224
|
+
themesQuarantined: themeResult.quarantined,
|
|
2200
2225
|
packageJsonMerged: true,
|
|
2201
2226
|
obsoleteRemoved: obsoleteFiles
|
|
2202
2227
|
};
|