create-ampless 1.0.0-alpha.80 → 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.
Files changed (2) hide show
  1. package/dist/index.js +38 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1930,10 +1930,21 @@ function isProtected(relPath) {
1930
1930
  if (SEED_IF_MISSING_PATTERN.test(relPath)) return false;
1931
1931
  return PROTECTED_PATTERNS.some((re) => re.test(relPath));
1932
1932
  }
1933
+ var NON_THEME_TEMPLATE_PREFIXES = ["plugin-"];
1934
+ function isThemeDirName(name) {
1935
+ if (name === "_shared") return false;
1936
+ for (const prefix of NON_THEME_TEMPLATE_PREFIXES) {
1937
+ if (name.startsWith(prefix)) return false;
1938
+ }
1939
+ return true;
1940
+ }
1941
+ function isQuarantinedThemeName(name) {
1942
+ return !isThemeDirName(name);
1943
+ }
1933
1944
  async function listShippedThemes(templatesRoot) {
1934
1945
  if (!existsSync5(templatesRoot)) return [];
1935
1946
  const entries = await readdir3(templatesRoot, { withFileTypes: true });
1936
- return entries.filter((e) => e.isDirectory() && e.name !== "_shared").map((e) => e.name).sort();
1947
+ return entries.filter((e) => e.isDirectory() && isThemeDirName(e.name)).map((e) => e.name).sort();
1937
1948
  }
1938
1949
  var USER_OWNED_THEME_FILES = /* @__PURE__ */ new Set(["README.md", ".gitignore"]);
1939
1950
  function isUserOwnedThemeFile(path) {
@@ -1961,6 +1972,16 @@ async function syncThemes(destDir, templatesRoot) {
1961
1972
  const shipped = await listShippedThemes(templatesRoot);
1962
1973
  const themesDir = join3(destDir, "themes");
1963
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
+ }
1964
1985
  for (const name of shipped) {
1965
1986
  const src = join3(templatesRoot, name);
1966
1987
  const dst = join3(themesDir, name);
@@ -1974,10 +1995,12 @@ async function syncThemes(destDir, templatesRoot) {
1974
1995
  }
1975
1996
  const installed = await discoverInstalledThemes(destDir);
1976
1997
  const shippedSet = new Set(shipped);
1977
- const preserved = installed.filter((t) => !shippedSet.has(t));
1998
+ const preserved = installed.filter(
1999
+ (t) => !shippedSet.has(t) && !isQuarantinedThemeName(t)
2000
+ );
1978
2001
  const all = [...shipped, ...preserved];
1979
2002
  await writeFile3(join3(destDir, "themes-registry.ts"), buildRegistry(all), "utf-8");
1980
- return { synced: shipped, preserved };
2003
+ return { synced: shipped, preserved, quarantined };
1981
2004
  }
1982
2005
  async function walkDir(dir, base, out) {
1983
2006
  const entries = await readdir3(dir, { withFileTypes: true });
@@ -2106,7 +2129,10 @@ async function runUpgradeIn(destDir, sharedDir, opts = {}) {
2106
2129
  const seedSkipped = classification.seed.filter((r) => existsSync5(join3(destDir, r)));
2107
2130
  const shippedThemes = themeSyncEnabled ? await listShippedThemes(templatesRoot) : [];
2108
2131
  const existingThemes = themeSyncEnabled ? await discoverInstalledThemes(destDir) : [];
2109
- const preservedThemes = existingThemes.filter((t) => !shippedThemes.includes(t));
2132
+ const quarantinedThemesPreview = existingThemes.filter(isQuarantinedThemeName);
2133
+ const preservedThemes = existingThemes.filter(
2134
+ (t) => !shippedThemes.includes(t) && !isQuarantinedThemeName(t)
2135
+ );
2110
2136
  const obsoleteFiles = await findObsoleteFiles(destDir, sharedDir);
2111
2137
  log3.info(
2112
2138
  `replace: ${pc3.green(`${replaceNew.length} added`)} / ${pc3.yellow(`${replaceUpdate.length} updated`)}`
@@ -2121,6 +2147,11 @@ async function runUpgradeIn(destDir, sharedDir, opts = {}) {
2121
2147
  log3.info(
2122
2148
  `themes: ${pc3.cyan(`${shippedThemes.length} default themes synced`)} / ${pc3.dim(`${preservedThemes.length} custom (my-*) themes preserved`)}`
2123
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
+ }
2124
2155
  }
2125
2156
  if (obsoleteFiles.length > 0) {
2126
2157
  log3.info(`cleanup: ${pc3.yellow(`${obsoleteFiles.length} removed`)} (files under ampless-managed app/ paths that no longer exist in the template)`);
@@ -2134,6 +2165,7 @@ async function runUpgradeIn(destDir, sharedDir, opts = {}) {
2134
2165
  protected: classification.protected,
2135
2166
  themesSynced: shippedThemes,
2136
2167
  themesPreserved: preservedThemes,
2168
+ themesQuarantined: quarantinedThemesPreview,
2137
2169
  packageJsonMerged: false,
2138
2170
  obsoleteRemoved: obsoleteFiles
2139
2171
  };
@@ -2148,7 +2180,7 @@ async function runUpgradeIn(destDir, sharedDir, opts = {}) {
2148
2180
  const dst = join3(destDir, rel);
2149
2181
  await copyWithSubstitution(src, dst, vars);
2150
2182
  }
2151
- const themeResult = themeSyncEnabled ? await syncThemes(destDir, templatesRoot) : { synced: [], preserved: [] };
2183
+ const themeResult = themeSyncEnabled ? await syncThemes(destDir, templatesRoot) : { synced: [], preserved: [], quarantined: [] };
2152
2184
  await removeObsoleteFiles(destDir, obsoleteFiles);
2153
2185
  const templatePkgRaw = await readFile3(join3(sharedDir, "package.json"), "utf-8");
2154
2186
  const templatePkg = JSON.parse(templatePkgRaw);
@@ -2189,6 +2221,7 @@ async function runUpgradeIn(destDir, sharedDir, opts = {}) {
2189
2221
  protected: classification.protected,
2190
2222
  themesSynced: themeResult.synced,
2191
2223
  themesPreserved: themeResult.preserved,
2224
+ themesQuarantined: themeResult.quarantined,
2192
2225
  packageJsonMerged: true,
2193
2226
  obsoleteRemoved: obsoleteFiles
2194
2227
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ampless",
3
- "version": "1.0.0-alpha.80",
3
+ "version": "1.0.0-alpha.82",
4
4
  "description": "Create a new ampless project",
5
5
  "license": "MIT",
6
6
  "type": "module",