@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.js CHANGED
@@ -104,8 +104,8 @@ function validateThemeName(name) {
104
104
  return /^[a-z][a-z0-9-]*$/.test(name);
105
105
  }
106
106
  function pathExists(filePath) {
107
- const fs8 = __require("fs-extra");
108
- return fs8.existsSync(filePath);
107
+ const fs10 = __require("fs-extra");
108
+ return fs10.existsSync(filePath);
109
109
  }
110
110
  function validateCategory(category) {
111
111
  const validCategories = [
@@ -223,18 +223,16 @@ function getProjectRoot() {
223
223
  }
224
224
  function getThemesDir() {
225
225
  const root = getProjectRoot();
226
- const themesDir = path__default.default.join(root, "themes");
227
- if (fs__default.default.existsSync(themesDir)) {
228
- return themesDir;
229
- }
230
- return path__default.default.join(root, "src/themes");
226
+ if (fs__default.default.existsSync(path__default.default.join(root, "themes"))) return path__default.default.join(root, "themes");
227
+ if (fs__default.default.existsSync(path__default.default.join(root, "src/themes"))) return path__default.default.join(root, "src/themes");
228
+ return path__default.default.dirname(root);
231
229
  }
232
230
  function getFeaturesDir() {
233
231
  return path__default.default.join(getProjectRoot(), "src/features");
234
232
  }
235
233
  function isOneXProject() {
236
234
  const root = getProjectRoot();
237
- return fs__default.default.existsSync(path__default.default.join(root, "themes")) || fs__default.default.existsSync(path__default.default.join(root, "src/themes"));
235
+ return fs__default.default.existsSync(path__default.default.join(root, "themes")) || fs__default.default.existsSync(path__default.default.join(root, "src/themes")) || fs__default.default.existsSync(path__default.default.join(root, "theme.config.ts")) || fs__default.default.existsSync(path__default.default.join(root, "bundle-entry.ts"));
238
236
  }
239
237
  function ensureOneXProject() {
240
238
  if (!isOneXProject()) {
@@ -699,6 +697,14 @@ export const homePageConfig: PageConfig = {
699
697
  async function createSectionCommand(name, options) {
700
698
  logger.header("Create New Section");
701
699
  ensureOneXProject();
700
+ if (!options.theme) {
701
+ const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
702
+ (f) => fs__default.default.existsSync(path__default.default.join(process.cwd(), f))
703
+ );
704
+ if (isStandaloneTheme) {
705
+ options.theme = path__default.default.basename(process.cwd());
706
+ }
707
+ }
702
708
  const sectionName = toKebabCase(name);
703
709
  if (!validateName(sectionName)) {
704
710
  logger.error(
@@ -930,6 +936,14 @@ ${hasTemplate ? `export { ${data.sectionNamePascal}Default } from "./${data.sect
930
936
  async function createBlockCommand(name, options) {
931
937
  logger.header("Create New Block");
932
938
  ensureOneXProject();
939
+ if (!options.theme) {
940
+ const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
941
+ (f) => fs__default.default.existsSync(path__default.default.join(process.cwd(), f))
942
+ );
943
+ if (isStandaloneTheme) {
944
+ options.theme = path__default.default.basename(process.cwd());
945
+ }
946
+ }
933
947
  const blockName = toKebabCase(name);
934
948
  if (!validateName(blockName)) {
935
949
  logger.error(
@@ -1499,8 +1513,8 @@ async function buildCommand(options) {
1499
1513
  process.exit(1);
1500
1514
  }
1501
1515
  } else {
1502
- const manifestPath = path__default.default.join(process.cwd(), "manifest.ts");
1503
- if (fs__default.default.existsSync(manifestPath)) {
1516
+ const isThemeDir = ["theme.config.ts", "bundle-entry.ts", "manifest.ts"].some((f) => fs__default.default.existsSync(path__default.default.join(process.cwd(), f)));
1517
+ if (isThemeDir) {
1504
1518
  themePath = process.cwd();
1505
1519
  themeName = path__default.default.basename(themePath);
1506
1520
  logger.info(`Building current theme: ${themeName}`);