zoho-sites-dev-cli 0.0.0-stage → 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 +396 -2
- package/bin/zoho-sites-dev-cli.js +108 -0
- package/config/default.json +26 -0
- package/index.js +6 -0
- package/package.json +55 -4
- package/src/commands/auth.js +125 -0
- package/src/commands/create.js +175 -0
- package/src/commands/deploy.js +409 -0
- package/src/commands/generate-zip.js +49 -0
- package/src/commands/index.js +23 -0
- package/src/commands/init-tailwind.js +57 -0
- package/src/commands/init.js +449 -0
- package/src/commands/install.js +90 -0
- package/src/commands/login.js +253 -0
- package/src/commands/pull.js +41 -0
- package/src/commands/serve.js +163 -0
- package/src/compilers/css-compiler.js +230 -0
- package/src/compilers/css-ignore-loader.js +33 -0
- package/src/compilers/plugins/index.js +12 -0
- package/src/compilers/plugins/root-selector-transform-plugin.js +79 -0
- package/src/compilers/tailwind-compiler.js +102 -0
- package/src/compilers/webpack-compiler.js +512 -0
- package/src/compilers/webpack-config.js +103 -0
- package/src/config/constants.js +164 -0
- package/src/config/environments/audiences.js +19 -0
- package/src/config/environments/index.js +78 -0
- package/src/config/environments/internal.js +72 -0
- package/src/config/environments/production.js +54 -0
- package/src/locales/en.json +216 -0
- package/src/services/devServer.js +583 -0
- package/src/services/oauthService.js +796 -0
- package/src/templates/component/fields.json +6 -0
- package/src/templates/component/index.js +11 -0
- package/src/templates/component/llm.md +9 -0
- package/src/templates/component/meta.json +9 -0
- package/src/templates/component/styles.css +3 -0
- package/src/templates/oauth/complete.html +41 -0
- package/src/templates/oauth/error.html +69 -0
- package/src/templates/oauth/invalid-request.html +58 -0
- package/src/templates/oauth/loading.html +80 -0
- package/src/templates/oauth/not-found.html +33 -0
- package/src/templates/oauth/success.html +70 -0
- package/src/templates/oauth/timeout.html +56 -0
- package/src/templates/oauth/token-error.html +57 -0
- package/src/utils/cliName.js +35 -0
- package/src/utils/configUtil.js +67 -0
- package/src/utils/httpUtil.js +351 -0
- package/src/utils/i18n.js +222 -0
- package/src/utils/loadingUtil.js +190 -0
- package/src/utils/secureConfig.js +75 -0
- package/src/utils/secureStorage.js +230 -0
- package/src/utils/templateLoader.js +89 -0
- package/src/utils/urlUtil.js +372 -0
package/README.md
CHANGED
|
@@ -1,3 +1,397 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ZS CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Command line interface for managing Zoho Sites components.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g zoho-sites-dev-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
**Note:** This CLI tool uses CommonJS modules and requires Node.js 14+ for compatibility.
|
|
12
|
+
|
|
13
|
+
## Available Commands
|
|
14
|
+
|
|
15
|
+
- `zoho-sites-dev-cli login` - Login to your account
|
|
16
|
+
- `zoho-sites-dev-cli logout` - Logout from your account
|
|
17
|
+
- `zoho-sites-dev-cli whoami` - Show current user information
|
|
18
|
+
- `zoho-sites-dev-cli status` - Show authentication status
|
|
19
|
+
- `zoho-sites-dev-cli init` - Initialize a new project
|
|
20
|
+
- `zoho-sites-dev-cli init-tailwind` - Add Tailwind CSS config to the current project
|
|
21
|
+
- `zoho-sites-dev-cli pull` - Pull components from server
|
|
22
|
+
- `zoho-sites-dev-cli create <component_name>` - Create a new component
|
|
23
|
+
- `zoho-sites-dev-cli push <component_name>` - Push a component to server
|
|
24
|
+
- `zoho-sites-dev-cli serve [--no-open]` - Start development server (use --no-open to prevent browser from opening)
|
|
25
|
+
|
|
26
|
+
- `zoho-sites-dev-cli deploy` - Deploy all components to server
|
|
27
|
+
- `zoho-sites-dev-cli generate-zip [-o path]` - Generate deployment zip (widgets.zip) for server team verification
|
|
28
|
+
- `zoho-sites-dev-cli install <pkg> [pkg2 ...]` - Create `package.json` if missing and run `npm install` for the specified packages. Use `-D`/`--dev` to install as devDependencies.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
1. Install the CLI:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install -g zoho-sites-dev-cli
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
2. Login to your account:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
zoho-sites-dev-cli login
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
3. Initialize a new project:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
zoho-sites-dev-cli init
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
4. Create a new component:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
zoho-sites-dev-cli create my-component
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
5. Start development server:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
zoho-sites-dev-cli serve
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
6. Deploy your components:
|
|
64
|
+
```bash
|
|
65
|
+
zoho-sites-dev-cli deploy
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Usage Examples
|
|
69
|
+
|
|
70
|
+
### Authentication
|
|
71
|
+
|
|
72
|
+
Login to your account:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Install packages (creates package.json if missing)
|
|
76
|
+
zoho-sites-dev-cli install axios @babel/core
|
|
77
|
+
|
|
78
|
+
# Install as devDependencies
|
|
79
|
+
zoho-sites-dev-cli install -D jest @babel/preset-env
|
|
80
|
+
|
|
81
|
+
# Start the login process
|
|
82
|
+
zoho-sites-dev-cli login
|
|
83
|
+
|
|
84
|
+
# Check your login status
|
|
85
|
+
zoho-sites-dev-cli status
|
|
86
|
+
|
|
87
|
+
# Show your current user info
|
|
88
|
+
zoho-sites-dev-cli whoami
|
|
89
|
+
|
|
90
|
+
# Logout when done
|
|
91
|
+
zoho-sites-dev-cli logout
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Component Management
|
|
95
|
+
|
|
96
|
+
Create and manage components:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Initialize a new project (automatically handles namespace setup)
|
|
100
|
+
zoho-sites-dev-cli init
|
|
101
|
+
|
|
102
|
+
# Create a new component
|
|
103
|
+
zoho-sites-dev-cli create my-component
|
|
104
|
+
|
|
105
|
+
# Pull existing components
|
|
106
|
+
zoho-sites-dev-cli pull
|
|
107
|
+
|
|
108
|
+
# Push a component to server
|
|
109
|
+
zoho-sites-dev-cli push my-component
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The `zoho-sites-dev-cli init` command will:
|
|
115
|
+
|
|
116
|
+
1. Fetch your account details (`GET /api/v3/account`) to resolve your asoid (used as `x-site-id` for resource APIs)
|
|
117
|
+
2. Fetch available workspaces and let you select one (or auto-select if you have only one)
|
|
118
|
+
3. Fetch apps in that workspace and let you select an app (or auto-select if you have only one)
|
|
119
|
+
4. Create project structure with configuration files:
|
|
120
|
+
- `.zs` at project root (project metadata including account `asoid`, workspace, app name, and namespace)
|
|
121
|
+
- `webpack.overrides.js` for optional bundling; use `zoho-sites-dev-cli init-tailwind` to add Tailwind CSS
|
|
122
|
+
- `package.json` initialized with the current user as author and handy scripts
|
|
123
|
+
5. Optionally, run `zoho-sites-dev-cli pull` to fetch components (reads `<siteDomain>/<namespace>/__widgets/dist/meta.json` and downloads component files into your project with a progress bar)
|
|
124
|
+
|
|
125
|
+
Resulting structure example:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
{siteName}/
|
|
129
|
+
├── .zs
|
|
130
|
+
├── config.js
|
|
131
|
+
├── package.json
|
|
132
|
+
└── [components...]
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Development
|
|
136
|
+
|
|
137
|
+
Start the development server with automatic file watching:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# Start server with default settings (opens browser automatically)
|
|
141
|
+
zoho-sites-dev-cli serve
|
|
142
|
+
|
|
143
|
+
# Start server without opening browser
|
|
144
|
+
zoho-sites-dev-cli serve --no-open
|
|
145
|
+
|
|
146
|
+
# Server automatically watches for file changes and clears cache
|
|
147
|
+
# Access components at http://localhost:8083
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**File Watching Features:**
|
|
151
|
+
|
|
152
|
+
- **Automatic Cache Clearing:** Changes to component files automatically clear relevant cache
|
|
153
|
+
- **Real-time Updates:** Modify `index.js`, `styles.css`, `fields.json`, or `meta.json` files and see changes immediately
|
|
154
|
+
- **Smart Invalidation:** Only clears cache for changed files, not entire cache
|
|
155
|
+
- **Console Feedback:** Real-time logging shows which files changed and cache clearing actions
|
|
156
|
+
- **Cross-platform:** Works on macOS, Linux, and Windows
|
|
157
|
+
- **👀 File Watching:** Automatic cache clearing when files change
|
|
158
|
+
|
|
159
|
+
### Optional: Project Webpack Bundling for Components
|
|
160
|
+
|
|
161
|
+
The dev server can bundle components using your project's Webpack config. If present, it will prefer a Webpack build over the internal Babel compiler.
|
|
162
|
+
|
|
163
|
+
- Place your config at `zbs/webpack.config.js` (preferred) or `webpack.config.js` in your project root
|
|
164
|
+
- All component folders in the project directory are discovered automatically
|
|
165
|
+
- The following env vars are passed to your config:
|
|
166
|
+
- `WIDGETS`/`COMPONENT_LIST`: array of component directory names
|
|
167
|
+
- `BUILD_ONE`: boolean, true when building more than one
|
|
168
|
+
- `COMPONENT`: name when building exactly one
|
|
169
|
+
- `NAMESPACE`: your project namespace (defaults to `zbs` if not provided)
|
|
170
|
+
|
|
171
|
+
Sample config shape (adapt as needed):
|
|
172
|
+
|
|
173
|
+
```js
|
|
174
|
+
const path = require('path');
|
|
175
|
+
const webpack = require('webpack');
|
|
176
|
+
|
|
177
|
+
module.exports = (env = {}) => {
|
|
178
|
+
const singleComponent = !!env.COMPONENT;
|
|
179
|
+
const buildOne = !!env.BUILD_ONE;
|
|
180
|
+
const componentName = env.COMPONENT;
|
|
181
|
+
const entry = buildOne
|
|
182
|
+
? {
|
|
183
|
+
'zbs-component1': path.resolve(__dirname, 'src/entries/component1.entry.js'),
|
|
184
|
+
'zbs-speaker': path.resolve(__dirname, 'src/entries/speaker.entry.js'),
|
|
185
|
+
'zbs-sponsor': path.resolve(__dirname, 'src/entries/sponsor.entry.js'),
|
|
186
|
+
}
|
|
187
|
+
: singleComponent
|
|
188
|
+
? { [`zbs-${componentName}`]: path.resolve(__dirname, 'src/register-one.js') }
|
|
189
|
+
: { zbs: [path.resolve(__dirname, 'src/index.js'), path.resolve(__dirname, 'src/register.js')] };
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
entry,
|
|
193
|
+
output: {
|
|
194
|
+
path: path.resolve(__dirname, 'dist'),
|
|
195
|
+
filename: '[name].umd.js',
|
|
196
|
+
library: { name: 'ZBSWidgets', type: 'umd' },
|
|
197
|
+
chunkFilename: '[name].umd.js',
|
|
198
|
+
umdNamedDefine: true,
|
|
199
|
+
globalObject: "typeof self !== 'undefined' ? self : this",
|
|
200
|
+
clean: true,
|
|
201
|
+
},
|
|
202
|
+
module: {
|
|
203
|
+
rules: [
|
|
204
|
+
{
|
|
205
|
+
test: /\.(js|jsx)$/,
|
|
206
|
+
exclude: /node_modules/,
|
|
207
|
+
use: {
|
|
208
|
+
loader: 'babel-loader',
|
|
209
|
+
options: {
|
|
210
|
+
presets: [
|
|
211
|
+
['@babel/preset-env', { targets: { browsers: ['defaults'] } }],
|
|
212
|
+
['@babel/preset-react', { runtime: 'classic' }],
|
|
213
|
+
],
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
],
|
|
218
|
+
},
|
|
219
|
+
resolve: { extensions: ['.js', '.jsx'] },
|
|
220
|
+
plugins: [new webpack.DefinePlugin({ COMPONENT_NAME: JSON.stringify(componentName || '') })],
|
|
221
|
+
externals: {
|
|
222
|
+
react: { commonjs: 'react', commonjs2: 'react', amd: 'react', root: 'React' },
|
|
223
|
+
'react-dom': { commonjs: 'react-dom', commonjs2: 'react-dom', amd: 'react-dom', root: 'ReactDOM' },
|
|
224
|
+
'react-dom/client': { commonjs: 'react-dom/client', commonjs2: 'react-dom/client', amd: 'react-dom/client', root: 'ReactDOM' },
|
|
225
|
+
},
|
|
226
|
+
optimization: { splitChunks: false, runtimeChunk: false },
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Dependencies typically required in your project for this setup:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
npm i -D webpack webpack-cli @babel/core babel-loader @babel/preset-env @babel/preset-react
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
#### File Watching Usage
|
|
238
|
+
|
|
239
|
+
**Test File Watching:**
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
# Start the development server
|
|
243
|
+
zoho-sites-dev-cli serve
|
|
244
|
+
|
|
245
|
+
# In another terminal, create a test component
|
|
246
|
+
mkdir test-component && cd test-component
|
|
247
|
+
echo 'console.log("Hello World");' > index.js
|
|
248
|
+
echo 'body { background: red; }' > styles.css
|
|
249
|
+
echo '{"name": "test"}' > fields.json
|
|
250
|
+
echo '{"version": "1.0"}' > meta.json
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**Console Output Example:**
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
🔄 File changed: test-component/index.js
|
|
257
|
+
🧹 Clearing cache for component: test-component, file: index.js
|
|
258
|
+
🧹 Cleared cache key: namespace_components_myproject
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
**File Watching Behavior:**
|
|
262
|
+
|
|
263
|
+
- **JS Changes:** Clears compiled JavaScript cache for all namespaces
|
|
264
|
+
- **CSS Changes:** Clears CSS cache for the specific component
|
|
265
|
+
- **JSON Changes:** Clears fields.json or meta.json cache as appropriate
|
|
266
|
+
- **Smart Invalidation:** Only clears relevant cache entries, not entire cache
|
|
267
|
+
- **Console Feedback:** Shows detailed cache clearing information
|
|
268
|
+
|
|
269
|
+
### Deploy Components
|
|
270
|
+
|
|
271
|
+
Deploy all components in the current directory:
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# Make sure you're in a ZS project directory
|
|
275
|
+
cd my-zs-project
|
|
276
|
+
|
|
277
|
+
# Deploy all components
|
|
278
|
+
zoho-sites-dev-cli deploy
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
The deploy command will:
|
|
282
|
+
|
|
283
|
+
1. Create a temporary directory
|
|
284
|
+
2. Copy all component folders
|
|
285
|
+
3. Create a zip file
|
|
286
|
+
4. Upload to the server
|
|
287
|
+
5. Clean up temporary files
|
|
288
|
+
|
|
289
|
+
## Features
|
|
290
|
+
|
|
291
|
+
- OAuth 2.0 authentication with automatic token refresh
|
|
292
|
+
- Secure credential storage in an encrypted file on your machine
|
|
293
|
+
- Component creation from templates
|
|
294
|
+
- Local development server with automatic file watching and cache clearing
|
|
295
|
+
- 👀 File watching with automatic cache clearing
|
|
296
|
+
- HTTPS support with automatic certificate generation
|
|
297
|
+
- Bulk component deployment
|
|
298
|
+
- Real-time file watching with smart cache invalidation
|
|
299
|
+
- Internationalization support
|
|
300
|
+
- Comprehensive error handling
|
|
301
|
+
- Cross-platform compatibility
|
|
302
|
+
- React and CSS compilers for component transformation
|
|
303
|
+
|
|
304
|
+
## Requirements
|
|
305
|
+
|
|
306
|
+
### System Requirements
|
|
307
|
+
|
|
308
|
+
- Node.js >= 14.0.0
|
|
309
|
+
- npm >= 6.0.0
|
|
310
|
+
- Git (for version control)
|
|
311
|
+
|
|
312
|
+
### Supported Operating Systems
|
|
313
|
+
|
|
314
|
+
- macOS
|
|
315
|
+
- Linux
|
|
316
|
+
- Windows 10/11
|
|
317
|
+
|
|
318
|
+
### Network Requirements
|
|
319
|
+
|
|
320
|
+
- Internet connection for authentication and deployment
|
|
321
|
+
- Access to Zoho Sites API endpoints
|
|
322
|
+
|
|
323
|
+
## Environment Variables
|
|
324
|
+
|
|
325
|
+
### Development
|
|
326
|
+
|
|
327
|
+
- `ZS_DEV_PORT` - Development server port (default: 3000)
|
|
328
|
+
- `ZS_DEV_HOST` - Development server host (default: localhost)
|
|
329
|
+
- `NODE_TLS_REJECT_UNAUTHORIZED` - Set to "0" to bypass SSL verification in development
|
|
330
|
+
|
|
331
|
+
### Logging
|
|
332
|
+
|
|
333
|
+
- `ZS_DEBUG` - Enable debug logging
|
|
334
|
+
- `ZS_LOG_LEVEL` - Set logging level (error, warn, info, debug)
|
|
335
|
+
|
|
336
|
+
## Security Notes
|
|
337
|
+
|
|
338
|
+
- Credentials are stored in an encrypted file in your home directory
|
|
339
|
+
- OAuth tokens are automatically refreshed
|
|
340
|
+
- HTTPS certificates are generated for local development
|
|
341
|
+
- API requests use secure HTTPS connections
|
|
342
|
+
- Sensitive data is never logged or exposed
|
|
343
|
+
|
|
344
|
+
## Compilers
|
|
345
|
+
|
|
346
|
+
The ZS SDK includes powerful compilers for transforming components and CSS:
|
|
347
|
+
|
|
348
|
+
### Webpack Compiler
|
|
349
|
+
|
|
350
|
+
Bundles components using webpack configuration for optimal performance:
|
|
351
|
+
|
|
352
|
+
```javascript
|
|
353
|
+
const { webpackCompiler } = require("zoho-sites-dev-cli/src/compilers/webpack-compiler.js");
|
|
354
|
+
|
|
355
|
+
// Bundle components using webpack
|
|
356
|
+
const components = ["MyComponent", "AnotherComponent"];
|
|
357
|
+
const bundledCode = await webpackCompiler.bundleWithWebpack(components);
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### CSS Compiler
|
|
361
|
+
|
|
362
|
+
Processes CSS with PostCSS, including prefixing, minification, and validation:
|
|
363
|
+
|
|
364
|
+
```javascript
|
|
365
|
+
const { compileCSS } = require("zoho-sites-dev-cli/src/compilers/css-compiler.js");
|
|
366
|
+
|
|
367
|
+
// Compile base64 encoded CSS
|
|
368
|
+
const base64CSS = Buffer.from(cssCode).toString("base64");
|
|
369
|
+
const processedCSS = await compileCSS(base64CSS, "ComponentName");
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Tailwind CSS
|
|
373
|
+
|
|
374
|
+
You can use Tailwind utility classes in your widgets. The SDK includes Tailwind at build time—you do not need to install `tailwindcss` in your project.
|
|
375
|
+
|
|
376
|
+
- **Config:** Add `tailwind.config.js` at project root by running `zoho-sites-dev-cli init-tailwind`. Edit `content` to your component paths (e.g. `["./*/index.js", "./*/**/*.js", "./*/styles.css"]`) so only used utilities are generated.
|
|
377
|
+
- **Scoping:** All Tailwind output is scoped with `[data-element-type^="namespace_"]` so styles apply only inside your widget roots and do not clash with other widgets.
|
|
378
|
+
- **Merge:** Tailwind CSS is built once per namespace and prepended to the combined `dist/styles.css` along with your component CSS.
|
|
379
|
+
- **Deploy:** Include `tailwind.config.js` (and optional `postcss.config.js`) in your project; they are copied into the deploy package automatically.
|
|
380
|
+
|
|
381
|
+
### Usage Examples
|
|
382
|
+
|
|
383
|
+
See `examples/compiler-usage.js` for complete usage examples.
|
|
384
|
+
|
|
385
|
+
**Note:** All imports in the examples use CommonJS `require()` syntax instead of ES modules.
|
|
386
|
+
|
|
387
|
+
## Support
|
|
388
|
+
|
|
389
|
+
For issues and feature requests, please:
|
|
390
|
+
|
|
391
|
+
1. Check the documentation
|
|
392
|
+
2. Search existing issues
|
|
393
|
+
3. Create a new issue if needed
|
|
394
|
+
|
|
395
|
+
## License
|
|
396
|
+
|
|
397
|
+
Copyright (c) Zoho Corporation. All rights reserved.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { Command } = require('commander'); //No I18N
|
|
4
|
+
const { login } = require('../src/commands/login.js'); //No I18N
|
|
5
|
+
const { logout, whoami, status } = require('../src/commands/auth.js'); //No I18N
|
|
6
|
+
const { init } = require('../src/commands/init.js'); //No I18N
|
|
7
|
+
const { initTailwind } = require('../src/commands/init-tailwind.js'); //No I18N
|
|
8
|
+
const { pull } = require('../src/commands/pull.js'); //No I18N
|
|
9
|
+
const { create } = require('../src/commands/create.js'); //No I18N
|
|
10
|
+
const { serve } = require('../src/commands/serve.js'); //No I18N
|
|
11
|
+
const { deploy } = require('../src/commands/deploy.js'); //No I18N
|
|
12
|
+
const { generateZip } = require('../src/commands/generate-zip.js'); //No I18N
|
|
13
|
+
const { install } = require('../src/commands/install.js'); //No I18N
|
|
14
|
+
|
|
15
|
+
const { i18n } = require('../src/utils/i18n.js'); //No I18N
|
|
16
|
+
const { getCliName } = require('../src/utils/cliName.js'); //No I18N
|
|
17
|
+
|
|
18
|
+
const program = new Command();
|
|
19
|
+
|
|
20
|
+
program
|
|
21
|
+
.name(getCliName())
|
|
22
|
+
.description(i18n.t('cli.description')) //No I18N
|
|
23
|
+
.version('1.0.0'); //No I18N
|
|
24
|
+
|
|
25
|
+
// Authentication commands
|
|
26
|
+
program
|
|
27
|
+
.command('login')
|
|
28
|
+
.description(i18n.t('commands.login.description')) //No I18N
|
|
29
|
+
.action(login);
|
|
30
|
+
|
|
31
|
+
program
|
|
32
|
+
.command('logout')
|
|
33
|
+
.description(i18n.t('commands.logout.description')) //No I18N
|
|
34
|
+
.action(logout);
|
|
35
|
+
|
|
36
|
+
program
|
|
37
|
+
.command('whoami')
|
|
38
|
+
.description(i18n.t('commands.whoami.description')) //No I18N
|
|
39
|
+
.action(whoami);
|
|
40
|
+
|
|
41
|
+
program
|
|
42
|
+
.command('status')
|
|
43
|
+
.description(i18n.t('commands.status.description')) //No I18N
|
|
44
|
+
.action(status);
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
// Init command
|
|
48
|
+
program
|
|
49
|
+
.command('init')
|
|
50
|
+
.description(i18n.t('commands.init.description')) //No I18N
|
|
51
|
+
.action(init);
|
|
52
|
+
|
|
53
|
+
program
|
|
54
|
+
.command('init-tailwind') //No I18N
|
|
55
|
+
.description(i18n.t('commands.initTailwind.description')) //No I18N
|
|
56
|
+
.action(initTailwind);
|
|
57
|
+
|
|
58
|
+
// Pull command
|
|
59
|
+
program
|
|
60
|
+
.command('pull')
|
|
61
|
+
.description(i18n.t('commands.pull.description')) //No I18N
|
|
62
|
+
.action(pull);
|
|
63
|
+
|
|
64
|
+
// Create command
|
|
65
|
+
program
|
|
66
|
+
.command('create <component_name>')
|
|
67
|
+
.description(i18n.t('commands.create.description')) //No I18N
|
|
68
|
+
.action(create);
|
|
69
|
+
|
|
70
|
+
// Install command
|
|
71
|
+
program
|
|
72
|
+
.command('install [packages...]')
|
|
73
|
+
.description(i18n.t('commands.install.description')) //No I18N
|
|
74
|
+
.option('-D, --dev', 'Install as devDependencies')
|
|
75
|
+
.action((packages, options) => install(packages, options));
|
|
76
|
+
|
|
77
|
+
// Serve command
|
|
78
|
+
program
|
|
79
|
+
.command('serve')
|
|
80
|
+
.description(i18n.t('commands.serve.description')) //No I18N
|
|
81
|
+
.option('--no-open', 'Do not automatically open the browser') //No I18N
|
|
82
|
+
.action(serve);
|
|
83
|
+
|
|
84
|
+
// Deploy command
|
|
85
|
+
program
|
|
86
|
+
.command('deploy')
|
|
87
|
+
.description(i18n.t('commands.deploy.description')) //No I18N
|
|
88
|
+
.action((options) => deploy(options));
|
|
89
|
+
|
|
90
|
+
// Generate zip command (for server team verification)
|
|
91
|
+
program
|
|
92
|
+
.command('generate-zip') //No I18N
|
|
93
|
+
.description(i18n.t('commands.generateZip.description')) //No I18N
|
|
94
|
+
.option('-o, --output <path>', 'Output path for zip file (default: ./widgets.zip)') //No I18N
|
|
95
|
+
.action((options) => generateZip(options));
|
|
96
|
+
|
|
97
|
+
// Handle unknown commands
|
|
98
|
+
program.on('command:*', () => {
|
|
99
|
+
i18n.error('cli.invalidCommand', program.args.join(' ')); //No I18N
|
|
100
|
+
process.exit(1);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
program.parse(process.argv);
|
|
104
|
+
|
|
105
|
+
// Show help if no command is provided
|
|
106
|
+
if (!process.argv.slice(2).length) {
|
|
107
|
+
program.outputHelp();
|
|
108
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"audience": "internal",
|
|
3
|
+
"oauth": {
|
|
4
|
+
"scope": "ZohoSites.resource.READ,ZohoSites.blogs.CREATE,zohoSites.blogs.READ,aaaserver.profile.read",
|
|
5
|
+
"accessType": "offline",
|
|
6
|
+
"prompt": "consent",
|
|
7
|
+
"defaultPort": 3030,
|
|
8
|
+
"clients": {
|
|
9
|
+
"localzoho": {
|
|
10
|
+
"clientId": "1000.BW3HGGDUV5JXCARZB65I9EAZN7R6IR"
|
|
11
|
+
},
|
|
12
|
+
"usdc": {
|
|
13
|
+
"clientId": "REPLACE_WITH_USDC_CLIENT_ID"
|
|
14
|
+
},
|
|
15
|
+
"indc": {
|
|
16
|
+
"clientId": "REPLACE_WITH_INDC_CLIENT_ID"
|
|
17
|
+
},
|
|
18
|
+
"eudc": {
|
|
19
|
+
"clientId": "REPLACE_WITH_EUDC_CLIENT_ID"
|
|
20
|
+
},
|
|
21
|
+
"audc": {
|
|
22
|
+
"clientId": "REPLACE_WITH_AUDC_CLIENT_ID"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zoho-sites-dev-cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "ZS CLI - Manage your site components",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"zoho-sites-dev-cli": "./bin/zoho-sites-dev-cli.js"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./index.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"bin/",
|
|
14
|
+
"src/",
|
|
15
|
+
"config/",
|
|
16
|
+
"index.js"
|
|
17
|
+
],
|
|
18
|
+
"keywords": [
|
|
19
|
+
"cli",
|
|
20
|
+
"zoho sites",
|
|
21
|
+
"site builder",
|
|
22
|
+
"site management",
|
|
23
|
+
"site builder management"
|
|
24
|
+
],
|
|
25
|
+
"author": "Zoho Corporation",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@babel/core": "^7.28.3",
|
|
29
|
+
"@babel/preset-env": "^7.28.3",
|
|
30
|
+
"@babel/preset-react": "^7.27.1",
|
|
31
|
+
"@babel/standalone": "^7.23.5",
|
|
32
|
+
"archiver": "^6.0.1",
|
|
33
|
+
"axios": "^1.6.7",
|
|
34
|
+
"babel-loader": "^10.0.0",
|
|
35
|
+
"chalk": "^4.1.2",
|
|
36
|
+
"chokidar": "^4.0.3",
|
|
37
|
+
"commander": "^11.1.0",
|
|
38
|
+
"config": "^4.4.1",
|
|
39
|
+
"cors": "^2.8.5",
|
|
40
|
+
"cssnano": "^6.0.1",
|
|
41
|
+
"express": "^4.18.2",
|
|
42
|
+
"inquirer": "^8.2.6",
|
|
43
|
+
"node-cache": "^5.1.2",
|
|
44
|
+
"open": "^8.4.2",
|
|
45
|
+
"postcss": "^8.4.32",
|
|
46
|
+
"postcss-nested": "^6.0.1",
|
|
47
|
+
"postcss-prefix-keyframe": "^0.0.1",
|
|
48
|
+
"postcss-prefix-selector": "^2.1.1",
|
|
49
|
+
"tailwindcss": "^3.4.0",
|
|
50
|
+
"webpack": "^5.91.0",
|
|
51
|
+
"webpack-merge": "^6.0.1"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=14.0.0"
|
|
55
|
+
},
|
|
56
|
+
"preferGlobal": true
|
|
57
|
+
}
|