@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/README.md +19 -4
- package/dist/cli.js +35 -17
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +34 -16
- package/dist/cli.mjs.map +1 -1
- package/dist/index.js +24 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/templates/default/package.json.ejs +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
3
4
|
import dotenv from 'dotenv';
|
|
4
5
|
import fs from 'fs-extra';
|
|
5
6
|
import ejs from 'ejs';
|
|
@@ -13,7 +14,6 @@ import archiver from 'archiver';
|
|
|
13
14
|
import FormData from 'form-data';
|
|
14
15
|
import fetch from 'node-fetch';
|
|
15
16
|
import { PutObjectCommand, GetObjectCommand, S3Client } from '@aws-sdk/client-s3';
|
|
16
|
-
import os from 'os';
|
|
17
17
|
import AdmZip from 'adm-zip';
|
|
18
18
|
|
|
19
19
|
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
@@ -156,18 +156,16 @@ function getProjectRoot() {
|
|
|
156
156
|
}
|
|
157
157
|
function getThemesDir() {
|
|
158
158
|
const root = getProjectRoot();
|
|
159
|
-
|
|
160
|
-
if (fs.existsSync(
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
return path.join(root, "src/themes");
|
|
159
|
+
if (fs.existsSync(path.join(root, "themes"))) return path.join(root, "themes");
|
|
160
|
+
if (fs.existsSync(path.join(root, "src/themes"))) return path.join(root, "src/themes");
|
|
161
|
+
return path.dirname(root);
|
|
164
162
|
}
|
|
165
163
|
function getFeaturesDir() {
|
|
166
164
|
return path.join(getProjectRoot(), "src/features");
|
|
167
165
|
}
|
|
168
166
|
function isOneXProject() {
|
|
169
167
|
const root = getProjectRoot();
|
|
170
|
-
return fs.existsSync(path.join(root, "themes")) || fs.existsSync(path.join(root, "src/themes"));
|
|
168
|
+
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"));
|
|
171
169
|
}
|
|
172
170
|
function ensureOneXProject() {
|
|
173
171
|
if (!isOneXProject()) {
|
|
@@ -661,6 +659,14 @@ export const homePageConfig: PageConfig = {
|
|
|
661
659
|
async function createSectionCommand(name, options) {
|
|
662
660
|
logger.header("Create New Section");
|
|
663
661
|
ensureOneXProject();
|
|
662
|
+
if (!options.theme) {
|
|
663
|
+
const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
|
|
664
|
+
(f) => fs.existsSync(path.join(process.cwd(), f))
|
|
665
|
+
);
|
|
666
|
+
if (isStandaloneTheme) {
|
|
667
|
+
options.theme = path.basename(process.cwd());
|
|
668
|
+
}
|
|
669
|
+
}
|
|
664
670
|
const sectionName = toKebabCase(name);
|
|
665
671
|
if (!validateName(sectionName)) {
|
|
666
672
|
logger.error(
|
|
@@ -892,6 +898,14 @@ ${hasTemplate ? `export { ${data.sectionNamePascal}Default } from "./${data.sect
|
|
|
892
898
|
async function createBlockCommand(name, options) {
|
|
893
899
|
logger.header("Create New Block");
|
|
894
900
|
ensureOneXProject();
|
|
901
|
+
if (!options.theme) {
|
|
902
|
+
const isStandaloneTheme = ["theme.config.ts", "bundle-entry.ts"].some(
|
|
903
|
+
(f) => fs.existsSync(path.join(process.cwd(), f))
|
|
904
|
+
);
|
|
905
|
+
if (isStandaloneTheme) {
|
|
906
|
+
options.theme = path.basename(process.cwd());
|
|
907
|
+
}
|
|
908
|
+
}
|
|
895
909
|
const blockName = toKebabCase(name);
|
|
896
910
|
if (!validateName(blockName)) {
|
|
897
911
|
logger.error(
|
|
@@ -1452,8 +1466,8 @@ async function validateCommand(options) {
|
|
|
1452
1466
|
}
|
|
1453
1467
|
themeToValidate = options.theme;
|
|
1454
1468
|
} else {
|
|
1455
|
-
const
|
|
1456
|
-
if (
|
|
1469
|
+
const isThemeDir = ["theme.config.ts", "bundle-entry.ts", "manifest.ts"].some((f) => fs.existsSync(path.join(process.cwd(), f)));
|
|
1470
|
+
if (isThemeDir) {
|
|
1457
1471
|
themeToValidate = path.basename(process.cwd());
|
|
1458
1472
|
logger.info(`Validating current theme: ${themeToValidate}`);
|
|
1459
1473
|
} else {
|
|
@@ -1630,8 +1644,8 @@ async function buildCommand(options) {
|
|
|
1630
1644
|
process.exit(1);
|
|
1631
1645
|
}
|
|
1632
1646
|
} else {
|
|
1633
|
-
const
|
|
1634
|
-
if (
|
|
1647
|
+
const isThemeDir = ["theme.config.ts", "bundle-entry.ts", "manifest.ts"].some((f) => fs.existsSync(path.join(process.cwd(), f)));
|
|
1648
|
+
if (isThemeDir) {
|
|
1635
1649
|
themePath = process.cwd();
|
|
1636
1650
|
themeName = path.basename(themePath);
|
|
1637
1651
|
logger.info(`Building current theme: ${themeName}`);
|
|
@@ -1732,8 +1746,8 @@ async function packageCommand(options) {
|
|
|
1732
1746
|
process.exit(1);
|
|
1733
1747
|
}
|
|
1734
1748
|
} else {
|
|
1735
|
-
const
|
|
1736
|
-
if (
|
|
1749
|
+
const isThemeDir = ["theme.config.ts", "bundle-entry.ts", "manifest.ts"].some((f) => fs.existsSync(path.join(process.cwd(), f)));
|
|
1750
|
+
if (isThemeDir) {
|
|
1737
1751
|
themePath = process.cwd();
|
|
1738
1752
|
themeName = path.basename(themePath);
|
|
1739
1753
|
logger.info(`Packaging current theme: ${themeName}`);
|
|
@@ -2675,9 +2689,13 @@ async function cloneCommand(themeName, options) {
|
|
|
2675
2689
|
}
|
|
2676
2690
|
|
|
2677
2691
|
// src/cli.ts
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
dotenv.config({ path: path.join(projectRoot, ".env"), quiet: true });
|
|
2692
|
+
try {
|
|
2693
|
+
const projectRoot = getProjectRoot();
|
|
2694
|
+
dotenv.config({ path: path.join(projectRoot, ".env.local"), quiet: true });
|
|
2695
|
+
dotenv.config({ path: path.join(projectRoot, ".env"), quiet: true });
|
|
2696
|
+
} catch (e) {
|
|
2697
|
+
}
|
|
2698
|
+
dotenv.config({ path: path.join(os.homedir(), ".onex", ".env"), quiet: true });
|
|
2681
2699
|
var program = new Command();
|
|
2682
2700
|
program.name("onex").description("CLI tool for OneX theme development").version("0.1.0");
|
|
2683
2701
|
program.command("init").description("Create a new OneX theme project").argument("[project-name]", "Name of the project").option(
|