zoho-sites-dev-cli 1.0.0 → 1.0.1
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 +42 -47
- package/bin/zoho-sites-dev-cli.js +2 -1
- package/config/default.json +17 -9
- package/package.json +1 -1
- package/src/commands/auth.js +7 -18
- package/src/commands/deploy.js +40 -11
- package/src/commands/init.js +8 -7
- package/src/commands/install.js +2 -1
- package/src/commands/login.js +8 -3
- package/src/commands/serve.js +3 -2
- package/src/config/constants.js +45 -6
- package/src/config/environments/internal.js +2 -2
- package/src/config/environments/production.js +18 -3
- package/src/locales/en.json +26 -26
- package/src/services/devServer.js +115 -21
- package/src/services/oauthService.js +135 -11
- package/src/templates/component/meta.json +1 -1
- package/src/utils/cliName.js +35 -0
- package/src/utils/configUtil.js +3 -2
- package/src/utils/i18n.js +19 -2
- package/src/utils/urlUtil.js +6 -5
package/src/utils/configUtil.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const { CONFIG_FILE_NAME } = require('../config/constants.js');
|
|
4
|
+
const { getCliName } = require('./cliName.js');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Read the project configuration file and return the configuration object
|
|
@@ -10,7 +11,7 @@ function readProjectConfig() {
|
|
|
10
11
|
const configPath = path.join(process.cwd(), CONFIG_FILE_NAME);
|
|
11
12
|
|
|
12
13
|
if (!fs.existsSync(configPath)) {
|
|
13
|
-
throw new Error(`Configuration file ${CONFIG_FILE_NAME} not found. Please run '
|
|
14
|
+
throw new Error(`Configuration file ${CONFIG_FILE_NAME} not found. Please run '${getCliName()} init' to initialize the project.`);
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
try {
|
|
@@ -20,7 +21,7 @@ function readProjectConfig() {
|
|
|
20
21
|
// Support both current format (namespace = UUID) and legacy (namespaceId)
|
|
21
22
|
const namespace = config.namespace || config.namespaceId;
|
|
22
23
|
if (!namespace) {
|
|
23
|
-
throw new Error(`Namespace not found in ${CONFIG_FILE_NAME}. Please run '
|
|
24
|
+
throw new Error(`Namespace not found in ${CONFIG_FILE_NAME}. Please run '${getCliName()} init' to initialize the project.`);
|
|
24
25
|
}
|
|
25
26
|
if (!config.namespace) {
|
|
26
27
|
config.namespace = namespace;
|
package/src/utils/i18n.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const { readFileSync } = require('fs');
|
|
2
2
|
const { join, dirname } = require('path');
|
|
3
3
|
const chalk = require('chalk');
|
|
4
|
+
const { getCliName } = require('./cliName.js');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* I18n utility for internationalization support
|
|
@@ -13,6 +14,16 @@ class I18n {
|
|
|
13
14
|
this.loadTranslations();
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Params always include {cli} so messages can say `{cli} login` and match
|
|
19
|
+
* the binary the user actually ran (zs / zoho-sites-cli / zoho-sites-dev-cli).
|
|
20
|
+
* @param {Object} [params]
|
|
21
|
+
* @returns {Object}
|
|
22
|
+
*/
|
|
23
|
+
withCliParams(params = {}) {
|
|
24
|
+
return { cli: getCliName(), ...params };
|
|
25
|
+
}
|
|
26
|
+
|
|
16
27
|
/**
|
|
17
28
|
* Load translations for the current locale
|
|
18
29
|
*/
|
|
@@ -107,14 +118,20 @@ class I18n {
|
|
|
107
118
|
if (params !== undefined) {
|
|
108
119
|
// Check if first parameter is an object (named placeholders)
|
|
109
120
|
if (typeof params === 'object' && params !== null && !Array.isArray(params)) {
|
|
110
|
-
return this.formatStringNamed(translation, params);
|
|
121
|
+
return this.formatStringNamed(translation, this.withCliParams(params));
|
|
111
122
|
} else {
|
|
112
123
|
// Legacy positional arguments support
|
|
113
124
|
const allArgs = [params, ...legacyArgs];
|
|
114
|
-
|
|
125
|
+
const formatted = this.formatString(translation, ...allArgs);
|
|
126
|
+
return this.formatStringNamed(formatted, this.withCliParams());
|
|
115
127
|
}
|
|
116
128
|
}
|
|
117
129
|
|
|
130
|
+
// Auto-resolve {cli} even when no other params were passed
|
|
131
|
+
if (typeof translation === 'string' && translation.includes('{cli}')) {
|
|
132
|
+
return this.formatStringNamed(translation, this.withCliParams());
|
|
133
|
+
}
|
|
134
|
+
|
|
118
135
|
return translation;
|
|
119
136
|
}
|
|
120
137
|
|
package/src/utils/urlUtil.js
CHANGED
|
@@ -22,6 +22,7 @@ const {
|
|
|
22
22
|
isValidEnvironmentForAudience,
|
|
23
23
|
} = require("../config/environments/index.js");
|
|
24
24
|
const SecureStorage = require("./secureStorage.js");
|
|
25
|
+
const { getCliName } = require("./cliName.js");
|
|
25
26
|
|
|
26
27
|
// ---------------------------------------------------------------------------
|
|
27
28
|
// Environments (backward-compatible export; full list depends on audience)
|
|
@@ -110,7 +111,7 @@ class UrlUtil {
|
|
|
110
111
|
*/
|
|
111
112
|
static async resolveAuthDomain(env) {
|
|
112
113
|
const environment = env || (await this.getEnvironment());
|
|
113
|
-
if (!environment) throw new Error(
|
|
114
|
+
if (!environment) throw new Error(`No environment configured. Please run \`${getCliName()} login\`.`);
|
|
114
115
|
|
|
115
116
|
const cfg = getEnvironmentById(AUDIENCE, environment);
|
|
116
117
|
if (!cfg) throw new Error(`Unknown environment: ${environment}`);
|
|
@@ -127,7 +128,7 @@ class UrlUtil {
|
|
|
127
128
|
*/
|
|
128
129
|
static async resolveSiteDomain(env) {
|
|
129
130
|
const environment = env || (await this.getEnvironment());
|
|
130
|
-
if (!environment) throw new Error(
|
|
131
|
+
if (!environment) throw new Error(`No environment configured. Please run \`${getCliName()} login\`.`);
|
|
131
132
|
|
|
132
133
|
const cfg = getEnvironmentById(AUDIENCE, environment);
|
|
133
134
|
if (!cfg) throw new Error(`Unknown environment: ${environment}`);
|
|
@@ -135,7 +136,7 @@ class UrlUtil {
|
|
|
135
136
|
if (cfg.siteDomain) return cfg.siteDomain;
|
|
136
137
|
|
|
137
138
|
const siteDomain = await SecureStorage.getDevSiteUrl();
|
|
138
|
-
if (!siteDomain) throw new Error(
|
|
139
|
+
if (!siteDomain) throw new Error(`Dev site URL not set. Please run \`${getCliName()} login\` again and provide the site URL.`);
|
|
139
140
|
return siteDomain;
|
|
140
141
|
}
|
|
141
142
|
|
|
@@ -149,7 +150,7 @@ class UrlUtil {
|
|
|
149
150
|
*/
|
|
150
151
|
static async resolveSiteBuilderDomain(siteId, env) {
|
|
151
152
|
const environment = env || (await this.getEnvironment());
|
|
152
|
-
if (!environment) throw new Error(
|
|
153
|
+
if (!environment) throw new Error(`No environment configured. Please run \`${getCliName()} login\`.`);
|
|
153
154
|
|
|
154
155
|
const cfg = getEnvironmentById(AUDIENCE, environment);
|
|
155
156
|
if (!cfg) throw new Error(`Unknown environment: ${environment}`);
|
|
@@ -164,7 +165,7 @@ class UrlUtil {
|
|
|
164
165
|
return devSiteBuilderUrl.replace("{siteId}", siteId);
|
|
165
166
|
}
|
|
166
167
|
const siteDomain = await SecureStorage.getDevSiteUrl();
|
|
167
|
-
if (!siteDomain) throw new Error(
|
|
168
|
+
if (!siteDomain) throw new Error(`Dev site URL not set. Please run \`${getCliName()} login\` again.`);
|
|
168
169
|
return siteDomain;
|
|
169
170
|
}
|
|
170
171
|
|