gasup 1.0.1 → 1.0.2
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 +30 -2
- package/dist/bin/gasup.js +12 -5
- package/dist/bundle.d.ts +1 -1
- package/dist/bundle.js +32 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,6 +5,7 @@ A simple CLI tool for bundling Google Apps Script projects with esbuild and the
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- **Simple bundling**: Bundle your TypeScript/JavaScript code into a single file optimized for Google Apps Script
|
|
8
|
+
- **Watch mode**: Automatically rebuild when files change during development
|
|
8
9
|
- **Easy configuration**: Interactive wizard to create configuration files
|
|
9
10
|
- **esbuild-gas-plugin integration**: Automatically handles GAS-specific optimizations
|
|
10
11
|
- **File management**: Automatically copies `appsscript.json` and HTML files to the output directory
|
|
@@ -50,6 +51,20 @@ pnpm gasup
|
|
|
50
51
|
yarn gasup
|
|
51
52
|
```
|
|
52
53
|
|
|
54
|
+
### `gasup --watch`
|
|
55
|
+
Watches for file changes and automatically rebuilds your project.
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Using npx
|
|
59
|
+
npx gasup --watch
|
|
60
|
+
|
|
61
|
+
# Using pnpm
|
|
62
|
+
pnpm gasup --watch
|
|
63
|
+
|
|
64
|
+
# Using yarn
|
|
65
|
+
yarn gasup --watch
|
|
66
|
+
```
|
|
67
|
+
|
|
53
68
|
### `gasup init`
|
|
54
69
|
Interactive wizard to create a `gasup.config.ts` configuration file.
|
|
55
70
|
|
|
@@ -91,6 +106,7 @@ Add these scripts to your `package.json` for easier access:
|
|
|
91
106
|
{
|
|
92
107
|
"scripts": {
|
|
93
108
|
"build": "gasup",
|
|
109
|
+
"dev": "gasup --watch",
|
|
94
110
|
"init": "gasup init",
|
|
95
111
|
"config": "gasup config"
|
|
96
112
|
}
|
|
@@ -102,6 +118,7 @@ Then you can run:
|
|
|
102
118
|
```bash
|
|
103
119
|
npm run init # Initialize configuration
|
|
104
120
|
npm run build # Bundle your project
|
|
121
|
+
npm run dev # Watch mode for development
|
|
105
122
|
npm run config # Show configuration
|
|
106
123
|
```
|
|
107
124
|
|
|
@@ -148,7 +165,8 @@ your-project/
|
|
|
148
165
|
1. **Bundling**: Uses esbuild with the esbuild-gas-plugin to bundle your code
|
|
149
166
|
2. **Optimization**: Automatically applies Google Apps Script-specific optimizations
|
|
150
167
|
3. **File copying**: Copies `appsscript.json` and any HTML files to the output directory
|
|
151
|
-
4. **
|
|
168
|
+
4. **Watch mode**: Monitors file changes and automatically rebuilds when needed
|
|
169
|
+
5. **Ready for deployment**: The bundled file is ready to be pushed to Google Apps Script
|
|
152
170
|
|
|
153
171
|
## Examples
|
|
154
172
|
|
|
@@ -164,11 +182,21 @@ npx gasup
|
|
|
164
182
|
clasp push
|
|
165
183
|
```
|
|
166
184
|
|
|
185
|
+
### Development with watch mode
|
|
186
|
+
```bash
|
|
187
|
+
# Start watch mode for development
|
|
188
|
+
npx gasup --watch
|
|
189
|
+
|
|
190
|
+
# In another terminal, push changes
|
|
191
|
+
clasp push
|
|
192
|
+
```
|
|
193
|
+
|
|
167
194
|
### Using npm scripts
|
|
168
195
|
```bash
|
|
169
196
|
# Add to package.json scripts
|
|
170
197
|
npm run init
|
|
171
|
-
npm run
|
|
198
|
+
npm run dev # Watch mode
|
|
199
|
+
npm run build # One-time build
|
|
172
200
|
clasp push
|
|
173
201
|
```
|
|
174
202
|
|
package/dist/bin/gasup.js
CHANGED
|
@@ -5,16 +5,23 @@ import { init } from '../init.js';
|
|
|
5
5
|
program
|
|
6
6
|
.name('gasup')
|
|
7
7
|
.description('CLI tool for Google Apps Script bundling')
|
|
8
|
-
.version('0.
|
|
8
|
+
.version('1.0.1');
|
|
9
9
|
// Main command (bundle execution)
|
|
10
10
|
program
|
|
11
11
|
.description('Bundle your Google Apps Script project')
|
|
12
|
-
.
|
|
12
|
+
.option('--watch', 'Watch for changes and rebuild automatically')
|
|
13
|
+
.action(async (options) => {
|
|
13
14
|
try {
|
|
14
15
|
const config = await loadConfigWithDefault();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
if (options.watch) {
|
|
17
|
+
console.log('📦 Starting watch mode...');
|
|
18
|
+
await bundle(config, true);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
console.log('📦 Bundling with esbuild...');
|
|
22
|
+
await bundle(config, false);
|
|
23
|
+
console.log('✅ Bundle completed');
|
|
24
|
+
}
|
|
18
25
|
}
|
|
19
26
|
catch (error) {
|
|
20
27
|
console.error('❌ Bundle failed:', error);
|
package/dist/bundle.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Config } from './types.js';
|
|
2
|
-
export declare function bundle(config: Config): Promise<void>;
|
|
2
|
+
export declare function bundle(config: Config, watch?: boolean): Promise<void>;
|
package/dist/bundle.js
CHANGED
|
@@ -2,23 +2,50 @@ import esbuild from 'esbuild';
|
|
|
2
2
|
import { GasPlugin } from 'esbuild-gas-plugin';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import path from 'path';
|
|
5
|
-
export async function bundle(config) {
|
|
5
|
+
export async function bundle(config, watch = false) {
|
|
6
6
|
const { appsScriptJsonPath, entryPoint, outputFile } = config;
|
|
7
7
|
const bundleEntries = [entryPoint];
|
|
8
|
-
|
|
8
|
+
const buildOptions = {
|
|
9
9
|
entryPoints: bundleEntries,
|
|
10
10
|
bundle: true,
|
|
11
11
|
outfile: outputFile,
|
|
12
12
|
plugins: [GasPlugin],
|
|
13
|
-
}
|
|
13
|
+
};
|
|
14
|
+
if (watch) {
|
|
15
|
+
// Watch mode
|
|
16
|
+
const context = await esbuild.context(buildOptions);
|
|
17
|
+
await context.watch();
|
|
18
|
+
// Initial build
|
|
19
|
+
await context.rebuild();
|
|
20
|
+
// Copy files after initial build
|
|
21
|
+
copyFiles(config);
|
|
22
|
+
console.log('👀 Watching for changes... (Press Ctrl+C to stop)');
|
|
23
|
+
// Keep the process running
|
|
24
|
+
process.on('SIGINT', () => {
|
|
25
|
+
context.dispose();
|
|
26
|
+
process.exit(0);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// Normal build
|
|
31
|
+
await esbuild.build(buildOptions);
|
|
32
|
+
copyFiles(config);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function copyFiles(config) {
|
|
36
|
+
const { appsScriptJsonPath, entryPoint, outputFile } = config;
|
|
14
37
|
const distDir = path.dirname(outputFile);
|
|
38
|
+
// Copy appsscript.json
|
|
15
39
|
fs.copyFileSync(appsScriptJsonPath, path.join(distDir, 'appsscript.json'));
|
|
16
40
|
// Copy HTML files to dist directory
|
|
17
|
-
|
|
18
|
-
|
|
41
|
+
const entryDir = path.dirname(entryPoint);
|
|
42
|
+
try {
|
|
19
43
|
const htmlFiles = fs.readdirSync(entryDir).filter(file => file.endsWith('.html'));
|
|
20
44
|
for (const htmlFile of htmlFiles) {
|
|
21
45
|
fs.copyFileSync(path.join(entryDir, htmlFile), path.join(distDir, htmlFile));
|
|
22
46
|
}
|
|
23
47
|
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
// Directory might not exist or be readable, ignore
|
|
50
|
+
}
|
|
24
51
|
}
|