@onexapis/cli 1.0.2 → 1.0.4

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.mjs CHANGED
@@ -89,8 +89,8 @@ function validateThemeName(name) {
89
89
  return /^[a-z][a-z0-9-]*$/.test(name);
90
90
  }
91
91
  function pathExists(filePath) {
92
- const fs8 = __require("fs-extra");
93
- return fs8.existsSync(filePath);
92
+ const fs10 = __require("fs-extra");
93
+ return fs10.existsSync(filePath);
94
94
  }
95
95
  function validateCategory(category) {
96
96
  const validCategories = [
@@ -208,18 +208,16 @@ function getProjectRoot() {
208
208
  }
209
209
  function getThemesDir() {
210
210
  const root = getProjectRoot();
211
- const themesDir = path.join(root, "themes");
212
- if (fs.existsSync(themesDir)) {
213
- return themesDir;
214
- }
215
- return path.join(root, "src/themes");
211
+ if (fs.existsSync(path.join(root, "themes"))) return path.join(root, "themes");
212
+ if (fs.existsSync(path.join(root, "src/themes"))) return path.join(root, "src/themes");
213
+ return path.dirname(root);
216
214
  }
217
215
  function getFeaturesDir() {
218
216
  return path.join(getProjectRoot(), "src/features");
219
217
  }
220
218
  function isOneXProject() {
221
219
  const root = getProjectRoot();
222
- return fs.existsSync(path.join(root, "themes")) || fs.existsSync(path.join(root, "src/themes"));
220
+ return fs.existsSync(path.join(root, "themes")) || fs.existsSync(path.join(root, "src/themes")) || fs.existsSync(path.join(root, "theme.config.ts")) || fs.existsSync(path.join(root, "bundle-entry.ts"));
223
221
  }
224
222
  function ensureOneXProject() {
225
223
  if (!isOneXProject()) {
@@ -684,6 +682,14 @@ export const homePageConfig: PageConfig = {
684
682
  async function createSectionCommand(name, options) {
685
683
  logger.header("Create New Section");
686
684
  ensureOneXProject();
685
+ if (!options.theme) {
686
+ const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
687
+ (f) => fs.existsSync(path.join(process.cwd(), f))
688
+ );
689
+ if (isStandaloneTheme) {
690
+ options.theme = path.basename(process.cwd());
691
+ }
692
+ }
687
693
  const sectionName = toKebabCase(name);
688
694
  if (!validateName(sectionName)) {
689
695
  logger.error(
@@ -915,6 +921,14 @@ ${hasTemplate ? `export { ${data.sectionNamePascal}Default } from "./${data.sect
915
921
  async function createBlockCommand(name, options) {
916
922
  logger.header("Create New Block");
917
923
  ensureOneXProject();
924
+ if (!options.theme) {
925
+ const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
926
+ (f) => fs.existsSync(path.join(process.cwd(), f))
927
+ );
928
+ if (isStandaloneTheme) {
929
+ options.theme = path.basename(process.cwd());
930
+ }
931
+ }
918
932
  const blockName = toKebabCase(name);
919
933
  if (!validateName(blockName)) {
920
934
  logger.error(
@@ -1484,8 +1498,8 @@ async function buildCommand(options) {
1484
1498
  process.exit(1);
1485
1499
  }
1486
1500
  } else {
1487
- const manifestPath = path.join(process.cwd(), "manifest.ts");
1488
- if (fs.existsSync(manifestPath)) {
1501
+ const isThemeDir = ["theme.config.ts", "bundle-entry.ts", "manifest.ts"].some((f) => fs.existsSync(path.join(process.cwd(), f)));
1502
+ if (isThemeDir) {
1489
1503
  themePath = process.cwd();
1490
1504
  themeName = path.basename(themePath);
1491
1505
  logger.info(`Building current theme: ${themeName}`);