@ciderjs/gasnuki 0.5.3 → 0.5.5

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.
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: commit-msg
3
+ description: Analyzes staged files, generates an appropriate commit message, and executes the commit.
4
+ ---
5
+
6
+ # Commit Message Skill
7
+
8
+ Generate a commit message for staged files and execute the commit.
9
+
10
+ ## Commit Procedure
11
+
12
+ 1. Read staged file differences using `git diff --staged`.
13
+ 2. Check the current branch using `git branch -a`.
14
+ - If on `main` branch or if the branch name does not reflect the staged changes, create and switch to a new branch:
15
+
16
+ ```powershell
17
+ git branch <new-branch-name>
18
+ git checkout <new-branch-name>
19
+ ```
20
+
21
+ 3. Review the last 3 commit messages using `git log -n 3` to understand the project's commit style.
22
+ 4. Generate a commit message based on:
23
+ - The staged changes
24
+ - The observed commit message style
25
+ 5. Execute the commit using `git commit` in a Windows 11 PowerShell environment.
26
+
27
+ ## Rules
28
+
29
+ - Only commit staged files. Do not include unstaged changes.
30
+ - Execute each git command separately. Do not chain commands.
package/README.ja.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # @ciderjs/gasnuki
2
2
 
3
3
  [![README-en](https://img.shields.io/badge/English-blue?logo=ReadMe)](./README.md)
4
- [![Test Coverage](https://img.shields.io/badge/test%20coverage-89.02%25-green)](https://github.com/luthpg/gasnuki)
4
+ [![Test Coverage](https://img.shields.io/badge/test%20coverage-89.47%25-green)](https://github.com/luthpg/gasnuki)
5
5
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
6
  [![npm version](https://img.shields.io/npm/v/@ciderjs/gasnuki.svg)](https://www.npmjs.com/package/@ciderjs/gasnuki)
7
- ![NPM Downloads](https://img.shields.io/npm/dw/@ciderjs/gasnuki)
7
+ [![NPM Downloads](https://img.shields.io/npm/dw/@ciderjs/gasnuki)](https://www.npmjs.com/package/@ciderjs/gasnuki)
8
8
  [![GitHub issues](https://img.shields.io/github/issues/luthpg/gasnuki.svg)](https://github.com/luthpg/gasnuki/issues)
9
9
 
10
10
  Google Apps Script クライアントサイドAPIの型定義・ユーティリティ
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # @ciderjs/gasnuki
2
2
 
3
3
  [![README-ja](https://img.shields.io/badge/日本語-blue?logo=ReadMe)](./README.ja.md)
4
- [![Test Coverage](https://img.shields.io/badge/test%20coverage-89.02%25-green)](https://github.com/luthpg/gasnuki)
4
+ [![Test Coverage](https://img.shields.io/badge/test%20coverage-89.47%25-green)](https://github.com/luthpg/gasnuki)
5
5
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
6
  [![npm version](https://img.shields.io/npm/v/@ciderjs/gasnuki.svg)](https://www.npmjs.com/package/@ciderjs/gasnuki)
7
- ![NPM Downloads](https://img.shields.io/npm/dw/@ciderjs/gasnuki)
7
+ [![NPM Downloads](https://img.shields.io/npm/dw/@ciderjs/gasnuki)](https://www.npmjs.com/package/@ciderjs/gasnuki)
8
8
  [![GitHub issues](https://img.shields.io/github/issues/luthpg/gasnuki.svg)](https://github.com/luthpg/gasnuki/issues)
9
9
 
10
10
  Type definitions and utilities for Google Apps Script client-side API
package/dist/cli.cjs CHANGED
@@ -4,7 +4,7 @@
4
4
  const path = require('node:path');
5
5
  const commander = require('commander');
6
6
  const index = require('./index.cjs');
7
- const config = require('./shared/gasnuki.CDe7f-cZ.cjs');
7
+ const config = require('./shared/gasnuki.BXbhblFz.cjs');
8
8
  require('chokidar');
9
9
  require('consola');
10
10
  require('node:crypto');
@@ -26,7 +26,7 @@ function _interopNamespaceCompat(e) {
26
26
 
27
27
  const path__namespace = /*#__PURE__*/_interopNamespaceCompat(path);
28
28
 
29
- const version = "0.5.3";
29
+ const version = "0.5.5";
30
30
 
31
31
  const parseArgs = async (command) => {
32
32
  const cliOpts = command.opts();
package/dist/cli.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  import * as path from 'node:path';
3
3
  import { Command } from 'commander';
4
4
  import { generateTypes } from './index.mjs';
5
- import { l as loadConfig } from './shared/gasnuki.BAmTBfMa.mjs';
5
+ import { l as loadConfig } from './shared/gasnuki.36-kDBNB.mjs';
6
6
  import 'chokidar';
7
7
  import 'consola';
8
8
  import 'node:crypto';
@@ -10,7 +10,7 @@ import 'node:fs';
10
10
  import 'ts-morph';
11
11
  import 'jiti';
12
12
 
13
- const version = "0.5.3";
13
+ const version = "0.5.5";
14
14
 
15
15
  const parseArgs = async (command) => {
16
16
  const cliOpts = command.opts();
package/dist/index.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  const path = require('node:path');
4
4
  const chokidar = require('chokidar');
5
5
  const consola = require('consola');
6
- const config = require('./shared/gasnuki.CDe7f-cZ.cjs');
6
+ const config = require('./shared/gasnuki.BXbhblFz.cjs');
7
7
  require('node:crypto');
8
8
  require('node:fs');
9
9
  require('ts-morph');
@@ -37,16 +37,23 @@ const generateTypes = async ({
37
37
  }
38
38
  const runGeneration = async (triggeredBy) => {
39
39
  const reason = triggeredBy ? ` (${triggeredBy})` : "";
40
- consola.consola.info(`Generating AppsScript types${reason}...`);
40
+ if (!watch) {
41
+ consola.consola.info(`Generating AppsScript types${reason}...`);
42
+ }
41
43
  try {
42
44
  await config.generateAppsScriptTypes({
43
45
  project,
44
46
  srcDir,
45
47
  outDir,
46
48
  outputFile,
47
- cache
49
+ cache,
50
+ quiet: watch
48
51
  });
49
- consola.consola.info("Type generation complete.");
52
+ if (watch) {
53
+ consola.consola.success(`Generated AppsScript types${reason}.`);
54
+ } else {
55
+ consola.consola.info("Type generation complete.");
56
+ }
50
57
  } catch (e) {
51
58
  consola.consola.error(`Type generation failed: ${e.message}`, e);
52
59
  }
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as path from 'node:path';
2
2
  import * as chokidar from 'chokidar';
3
3
  import { consola } from 'consola';
4
- import { g as generateAppsScriptTypes } from './shared/gasnuki.BAmTBfMa.mjs';
5
- export { d as defineConfig } from './shared/gasnuki.BAmTBfMa.mjs';
4
+ import { g as generateAppsScriptTypes } from './shared/gasnuki.36-kDBNB.mjs';
5
+ export { d as defineConfig } from './shared/gasnuki.36-kDBNB.mjs';
6
6
  import 'node:crypto';
7
7
  import 'node:fs';
8
8
  import 'ts-morph';
@@ -21,16 +21,23 @@ const generateTypes = async ({
21
21
  }
22
22
  const runGeneration = async (triggeredBy) => {
23
23
  const reason = triggeredBy ? ` (${triggeredBy})` : "";
24
- consola.info(`Generating AppsScript types${reason}...`);
24
+ if (!watch) {
25
+ consola.info(`Generating AppsScript types${reason}...`);
26
+ }
25
27
  try {
26
28
  await generateAppsScriptTypes({
27
29
  project,
28
30
  srcDir,
29
31
  outDir,
30
32
  outputFile,
31
- cache
33
+ cache,
34
+ quiet: watch
32
35
  });
33
- consola.info("Type generation complete.");
36
+ if (watch) {
37
+ consola.success(`Generated AppsScript types${reason}.`);
38
+ } else {
39
+ consola.info("Type generation complete.");
40
+ }
34
41
  } catch (e) {
35
42
  consola.error(`Type generation failed: ${e.message}`, e);
36
43
  }
@@ -19,21 +19,48 @@ const computeSourceHash = (sourceFiles) => {
19
19
  }
20
20
  return hash.digest("hex");
21
21
  };
22
+ const cleanType = (t) => t.replace(/import\(".*?"\)\.default\./g, "").replace(/import\(".*?"\)\./g, "");
23
+ const simplifyType = (type, node) => {
24
+ const aliasSymbol = type.getAliasSymbol();
25
+ if (aliasSymbol && ["Pick", "Omit"].includes(aliasSymbol.getName())) {
26
+ const props = type.getProperties();
27
+ const members = props.map((prop) => {
28
+ const name = prop.getName();
29
+ const declarations = prop.getDeclarations();
30
+ let propType = prop.getTypeAtLocation(node);
31
+ if ((!propType || propType.getText() === "any") && declarations.length > 0) {
32
+ propType = declarations[0].getType();
33
+ }
34
+ const typeText = cleanType(propType.getText(node));
35
+ const isOptional = prop.hasFlags(SymbolFlags.Optional);
36
+ return `${name}${isOptional ? "?" : ""}: ${typeText}`;
37
+ });
38
+ return `{ ${members.join("; ")} }`;
39
+ }
40
+ return null;
41
+ };
22
42
  const getInterfaceMethodDefinition_ = (name, node) => {
23
43
  const typeParameters = node.getTypeParameters?.() ?? [];
24
44
  const typeParamsString = typeParameters.length > 0 ? `<${typeParameters.map((tp) => tp.getText()).join(", ")}>` : "";
25
45
  const parameters = node.getParameters().map((param) => {
26
46
  const paramName = param.getName();
27
- const type = param.getTypeNode()?.getText() ?? param.getType().getText(node) ?? "any";
47
+ let type = param.getTypeNode()?.getText() ?? param.getType().getText(node) ?? "any";
48
+ const simplified = simplifyType(param.getType(), node);
49
+ if (simplified) {
50
+ type = simplified;
51
+ }
28
52
  const questionToken = param.hasQuestionToken() ? "?" : "";
29
53
  return `${paramName}${questionToken}: ${type}`;
30
54
  }).join(", ");
31
55
  const returnTypeNode = node.getReturnTypeNode();
32
56
  let returnType;
33
- if (returnTypeNode != null) {
57
+ const inferredReturnType = node.getReturnType();
58
+ const simplifiedReturn = simplifyType(inferredReturnType, node);
59
+ if (simplifiedReturn) {
60
+ returnType = simplifiedReturn;
61
+ } else if (returnTypeNode != null) {
34
62
  returnType = returnTypeNode.getText();
35
63
  } else {
36
- const inferredReturnType = node.getReturnType();
37
64
  if (inferredReturnType.isVoid()) {
38
65
  returnType = "void";
39
66
  } else {
@@ -54,7 +81,6 @@ const getInterfaceMethodDefinition_ = (name, node) => {
54
81
  `;
55
82
  }
56
83
  }
57
- const cleanType = (t) => t.replace(/import\(".*?"\)\.default\./g, "").replace(/import\(".*?"\)\./g, "");
58
84
  const cleanedReturnType = cleanType(returnType);
59
85
  const cleanedParameters = parameters.replace(
60
86
  /:\s*([^,;)]+)/g,
@@ -105,15 +131,18 @@ const findPackageJson_ = (startDir) => {
105
131
  return null;
106
132
  };
107
133
  const matchesExportValue_ = (node, targetPath) => {
134
+ const normalize = (p) => p.startsWith(".") ? p : `./${p}`;
135
+ const normalizedTarget = normalize(targetPath);
108
136
  if (typeof node === "string") {
109
- return node === targetPath || node === targetPath.replace(/\.d\.ts$/, ".js");
137
+ const normalizedNode = normalize(node);
138
+ return normalizedNode === normalizedTarget || normalizedNode === normalizedTarget.replace(/\.d\.ts$/, ".js");
110
139
  }
111
140
  if (typeof node === "object" && node !== null) {
112
- if (node.types && node.types === targetPath) {
141
+ if (node.types && matchesExportValue_(node.types, targetPath)) {
113
142
  return true;
114
143
  }
115
144
  for (const key in node) {
116
- if (matchesExportValue_(node[key], targetPath)) {
145
+ if (key !== "types" && matchesExportValue_(node[key], targetPath)) {
117
146
  return true;
118
147
  }
119
148
  }
@@ -137,7 +166,8 @@ const resolveNodeModuleSpecifier_ = (filePath) => {
137
166
  const exportValue = pkg.content.exports[key];
138
167
  if (matchesExportValue_(exportValue, relativePath)) {
139
168
  if (key === ".") return packageName;
140
- return path.posix.join(packageName, key);
169
+ const subPath = key.startsWith("./") ? key.slice(2) : key;
170
+ return `${packageName}/${subPath}`;
141
171
  }
142
172
  }
143
173
  }
@@ -159,15 +189,18 @@ const generateAppsScriptTypes = async ({
159
189
  outDir,
160
190
  outputFile,
161
191
  projectInstance,
162
- cache = true
192
+ cache = true,
163
193
  // Default to true
194
+ quiet
164
195
  }) => {
165
196
  const absoluteSrcDir = path.resolve(projectPath, srcDir);
166
197
  const absoluteOutDir = path.resolve(projectPath, outDir);
167
198
  const absoluteOutputFile = path.resolve(absoluteOutDir, outputFile);
168
- consola.info("Starting AppsScript type generation with gasnuki...");
169
- consola.info(` AppsScript Source Directory: ${absoluteSrcDir}`);
170
- consola.info(` Output File: ${absoluteOutputFile}`);
199
+ if (!quiet) {
200
+ consola.info("Starting AppsScript type generation with gasnuki...");
201
+ consola.info(` AppsScript Source Directory: ${absoluteSrcDir}`);
202
+ consola.info(` Output File: ${absoluteOutputFile}`);
203
+ }
171
204
  let tsConfigFilePath = path.resolve(projectPath, "tsconfig.json");
172
205
  if (fs.existsSync(path.resolve(projectPath, "tsconfig.app.json"))) {
173
206
  tsConfigFilePath = path.resolve(projectPath, "tsconfig.app.json");
@@ -180,14 +213,18 @@ const generateAppsScriptTypes = async ({
180
213
  const testFilesPattern = `!${path.join(absoluteSrcDir, "**/*.{test,spec}.ts").replace(/\\/g, "/")}`;
181
214
  project.addSourceFilesAtPaths([sourceFilesPattern, testFilesPattern]);
182
215
  const sourceFiles = project.getSourceFiles();
183
- consola.info(`Found ${sourceFiles.length} source file(s).`);
216
+ if (!quiet) {
217
+ consola.info(`Found ${sourceFiles.length} source file(s).`);
218
+ }
184
219
  if (cache) {
185
220
  const currentHash = computeSourceHash(sourceFiles);
186
221
  const cacheKey = absoluteOutputFile;
187
222
  if (generationCache.get(cacheKey) === currentHash && fs.existsSync(absoluteOutputFile)) {
188
- consola.success(
189
- `Skipping generation: Source files have not changed (Hash: ${currentHash.slice(0, 8)}).`
190
- );
223
+ if (!quiet) {
224
+ consola.success(
225
+ `Skipping generation: Source files have not changed (Hash: ${currentHash.slice(0, 8)}).`
226
+ );
227
+ }
191
228
  return;
192
229
  }
193
230
  }
@@ -527,7 +564,9 @@ const generateAppsScriptTypes = async ({
527
564
  }
528
565
  if (!fs.existsSync(absoluteOutDir)) {
529
566
  fs.mkdirSync(absoluteOutDir, { recursive: true });
530
- consola.info(`Created output directory: ${absoluteOutDir}`);
567
+ if (!quiet) {
568
+ consola.info(`Created output directory: ${absoluteOutDir}`);
569
+ }
531
570
  }
532
571
  const generatorName = "gasnuki";
533
572
  let outputContent = `// Auto-generated by ${generatorName}
@@ -556,14 +595,18 @@ const generateAppsScriptTypes = async ({
556
595
  ${formattedMethods}
557
596
  }
558
597
  `;
559
- consola.info(
560
- `Interface 'ServerScript' type definitions written to ${absoluteOutputFile} (${methodDefinitions.length} function(s), ${exportedTypeDefinitions.length + inlineDefinitions.size} type(s)).`
561
- );
598
+ if (!quiet) {
599
+ consola.info(
600
+ `Interface 'ServerScript' type definitions written to ${absoluteOutputFile} (${methodDefinitions.length} function(s), ${exportedTypeDefinitions.length + inlineDefinitions.size} type(s)).`
601
+ );
602
+ }
562
603
  } else {
563
604
  bodyContent += "export type ServerScripts = {}\n";
564
- consola.info(
565
- `Interface 'ServerScript' type definitions written to ${absoluteOutputFile} (no functions found).`
566
- );
605
+ if (!quiet) {
606
+ consola.info(
607
+ `Interface 'ServerScript' type definitions written to ${absoluteOutputFile} (no functions found).`
608
+ );
609
+ }
567
610
  }
568
611
  bodyContent += `
569
612
  // Auto-generated Types for GoogleAppsScript in client-side code
@@ -37,21 +37,48 @@ const computeSourceHash = (sourceFiles) => {
37
37
  }
38
38
  return hash.digest("hex");
39
39
  };
40
+ const cleanType = (t) => t.replace(/import\(".*?"\)\.default\./g, "").replace(/import\(".*?"\)\./g, "");
41
+ const simplifyType = (type, node) => {
42
+ const aliasSymbol = type.getAliasSymbol();
43
+ if (aliasSymbol && ["Pick", "Omit"].includes(aliasSymbol.getName())) {
44
+ const props = type.getProperties();
45
+ const members = props.map((prop) => {
46
+ const name = prop.getName();
47
+ const declarations = prop.getDeclarations();
48
+ let propType = prop.getTypeAtLocation(node);
49
+ if ((!propType || propType.getText() === "any") && declarations.length > 0) {
50
+ propType = declarations[0].getType();
51
+ }
52
+ const typeText = cleanType(propType.getText(node));
53
+ const isOptional = prop.hasFlags(tsMorph.SymbolFlags.Optional);
54
+ return `${name}${isOptional ? "?" : ""}: ${typeText}`;
55
+ });
56
+ return `{ ${members.join("; ")} }`;
57
+ }
58
+ return null;
59
+ };
40
60
  const getInterfaceMethodDefinition_ = (name, node) => {
41
61
  const typeParameters = node.getTypeParameters?.() ?? [];
42
62
  const typeParamsString = typeParameters.length > 0 ? `<${typeParameters.map((tp) => tp.getText()).join(", ")}>` : "";
43
63
  const parameters = node.getParameters().map((param) => {
44
64
  const paramName = param.getName();
45
- const type = param.getTypeNode()?.getText() ?? param.getType().getText(node) ?? "any";
65
+ let type = param.getTypeNode()?.getText() ?? param.getType().getText(node) ?? "any";
66
+ const simplified = simplifyType(param.getType(), node);
67
+ if (simplified) {
68
+ type = simplified;
69
+ }
46
70
  const questionToken = param.hasQuestionToken() ? "?" : "";
47
71
  return `${paramName}${questionToken}: ${type}`;
48
72
  }).join(", ");
49
73
  const returnTypeNode = node.getReturnTypeNode();
50
74
  let returnType;
51
- if (returnTypeNode != null) {
75
+ const inferredReturnType = node.getReturnType();
76
+ const simplifiedReturn = simplifyType(inferredReturnType, node);
77
+ if (simplifiedReturn) {
78
+ returnType = simplifiedReturn;
79
+ } else if (returnTypeNode != null) {
52
80
  returnType = returnTypeNode.getText();
53
81
  } else {
54
- const inferredReturnType = node.getReturnType();
55
82
  if (inferredReturnType.isVoid()) {
56
83
  returnType = "void";
57
84
  } else {
@@ -72,7 +99,6 @@ const getInterfaceMethodDefinition_ = (name, node) => {
72
99
  `;
73
100
  }
74
101
  }
75
- const cleanType = (t) => t.replace(/import\(".*?"\)\.default\./g, "").replace(/import\(".*?"\)\./g, "");
76
102
  const cleanedReturnType = cleanType(returnType);
77
103
  const cleanedParameters = parameters.replace(
78
104
  /:\s*([^,;)]+)/g,
@@ -123,15 +149,18 @@ const findPackageJson_ = (startDir) => {
123
149
  return null;
124
150
  };
125
151
  const matchesExportValue_ = (node, targetPath) => {
152
+ const normalize = (p) => p.startsWith(".") ? p : `./${p}`;
153
+ const normalizedTarget = normalize(targetPath);
126
154
  if (typeof node === "string") {
127
- return node === targetPath || node === targetPath.replace(/\.d\.ts$/, ".js");
155
+ const normalizedNode = normalize(node);
156
+ return normalizedNode === normalizedTarget || normalizedNode === normalizedTarget.replace(/\.d\.ts$/, ".js");
128
157
  }
129
158
  if (typeof node === "object" && node !== null) {
130
- if (node.types && node.types === targetPath) {
159
+ if (node.types && matchesExportValue_(node.types, targetPath)) {
131
160
  return true;
132
161
  }
133
162
  for (const key in node) {
134
- if (matchesExportValue_(node[key], targetPath)) {
163
+ if (key !== "types" && matchesExportValue_(node[key], targetPath)) {
135
164
  return true;
136
165
  }
137
166
  }
@@ -155,7 +184,8 @@ const resolveNodeModuleSpecifier_ = (filePath) => {
155
184
  const exportValue = pkg.content.exports[key];
156
185
  if (matchesExportValue_(exportValue, relativePath)) {
157
186
  if (key === ".") return packageName;
158
- return path__namespace.posix.join(packageName, key);
187
+ const subPath = key.startsWith("./") ? key.slice(2) : key;
188
+ return `${packageName}/${subPath}`;
159
189
  }
160
190
  }
161
191
  }
@@ -177,15 +207,18 @@ const generateAppsScriptTypes = async ({
177
207
  outDir,
178
208
  outputFile,
179
209
  projectInstance,
180
- cache = true
210
+ cache = true,
181
211
  // Default to true
212
+ quiet
182
213
  }) => {
183
214
  const absoluteSrcDir = path__namespace.resolve(projectPath, srcDir);
184
215
  const absoluteOutDir = path__namespace.resolve(projectPath, outDir);
185
216
  const absoluteOutputFile = path__namespace.resolve(absoluteOutDir, outputFile);
186
- consola.consola.info("Starting AppsScript type generation with gasnuki...");
187
- consola.consola.info(` AppsScript Source Directory: ${absoluteSrcDir}`);
188
- consola.consola.info(` Output File: ${absoluteOutputFile}`);
217
+ if (!quiet) {
218
+ consola.consola.info("Starting AppsScript type generation with gasnuki...");
219
+ consola.consola.info(` AppsScript Source Directory: ${absoluteSrcDir}`);
220
+ consola.consola.info(` Output File: ${absoluteOutputFile}`);
221
+ }
189
222
  let tsConfigFilePath = path__namespace.resolve(projectPath, "tsconfig.json");
190
223
  if (fs__namespace.existsSync(path__namespace.resolve(projectPath, "tsconfig.app.json"))) {
191
224
  tsConfigFilePath = path__namespace.resolve(projectPath, "tsconfig.app.json");
@@ -198,14 +231,18 @@ const generateAppsScriptTypes = async ({
198
231
  const testFilesPattern = `!${path__namespace.join(absoluteSrcDir, "**/*.{test,spec}.ts").replace(/\\/g, "/")}`;
199
232
  project.addSourceFilesAtPaths([sourceFilesPattern, testFilesPattern]);
200
233
  const sourceFiles = project.getSourceFiles();
201
- consola.consola.info(`Found ${sourceFiles.length} source file(s).`);
234
+ if (!quiet) {
235
+ consola.consola.info(`Found ${sourceFiles.length} source file(s).`);
236
+ }
202
237
  if (cache) {
203
238
  const currentHash = computeSourceHash(sourceFiles);
204
239
  const cacheKey = absoluteOutputFile;
205
240
  if (generationCache.get(cacheKey) === currentHash && fs__namespace.existsSync(absoluteOutputFile)) {
206
- consola.consola.success(
207
- `Skipping generation: Source files have not changed (Hash: ${currentHash.slice(0, 8)}).`
208
- );
241
+ if (!quiet) {
242
+ consola.consola.success(
243
+ `Skipping generation: Source files have not changed (Hash: ${currentHash.slice(0, 8)}).`
244
+ );
245
+ }
209
246
  return;
210
247
  }
211
248
  }
@@ -545,7 +582,9 @@ const generateAppsScriptTypes = async ({
545
582
  }
546
583
  if (!fs__namespace.existsSync(absoluteOutDir)) {
547
584
  fs__namespace.mkdirSync(absoluteOutDir, { recursive: true });
548
- consola.consola.info(`Created output directory: ${absoluteOutDir}`);
585
+ if (!quiet) {
586
+ consola.consola.info(`Created output directory: ${absoluteOutDir}`);
587
+ }
549
588
  }
550
589
  const generatorName = "gasnuki";
551
590
  let outputContent = `// Auto-generated by ${generatorName}
@@ -574,14 +613,18 @@ const generateAppsScriptTypes = async ({
574
613
  ${formattedMethods}
575
614
  }
576
615
  `;
577
- consola.consola.info(
578
- `Interface 'ServerScript' type definitions written to ${absoluteOutputFile} (${methodDefinitions.length} function(s), ${exportedTypeDefinitions.length + inlineDefinitions.size} type(s)).`
579
- );
616
+ if (!quiet) {
617
+ consola.consola.info(
618
+ `Interface 'ServerScript' type definitions written to ${absoluteOutputFile} (${methodDefinitions.length} function(s), ${exportedTypeDefinitions.length + inlineDefinitions.size} type(s)).`
619
+ );
620
+ }
580
621
  } else {
581
622
  bodyContent += "export type ServerScripts = {}\n";
582
- consola.consola.info(
583
- `Interface 'ServerScript' type definitions written to ${absoluteOutputFile} (no functions found).`
584
- );
623
+ if (!quiet) {
624
+ consola.consola.info(
625
+ `Interface 'ServerScript' type definitions written to ${absoluteOutputFile} (no functions found).`
626
+ );
627
+ }
585
628
  }
586
629
  bodyContent += `
587
630
  // Auto-generated Types for GoogleAppsScript in client-side code
package/dist/vite.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  const path = require('node:path');
4
4
  const consola = require('consola');
5
- const config = require('./shared/gasnuki.CDe7f-cZ.cjs');
5
+ const config = require('./shared/gasnuki.BXbhblFz.cjs');
6
6
  require('node:crypto');
7
7
  require('node:fs');
8
8
  require('ts-morph');
@@ -36,13 +36,13 @@ function gasnuki(options) {
36
36
  debounce(async () => {
37
37
  const reason = triggeredBy ? ` (triggered by: ${triggeredBy})` : "";
38
38
  console.log("");
39
- consola.consola.info(`[gasnuki] Generating AppsScript types${reason}...`);
40
39
  try {
41
40
  await config.generateAppsScriptTypes({
42
41
  ...gasnukiOptions,
43
- project: projectRoot
42
+ project: projectRoot,
43
+ quiet: true
44
44
  });
45
- consola.consola.success("[gasnuki] Type generation complete.");
45
+ consola.consola.success(`[gasnuki] Generated AppsScript types${reason}.`);
46
46
  } catch (e) {
47
47
  consola.consola.error(
48
48
  `[gasnuki] Type generation failed: ${e.message}`
@@ -54,31 +54,41 @@ function gasnuki(options) {
54
54
  name: "vite-plugin-gasnuki",
55
55
  apply: "serve",
56
56
  // Apply only in serve mode
57
- async configResolved(config$1) {
58
- projectRoot = config$1.root;
59
- const fileConfig = await config.loadConfig(projectRoot);
60
- const defaultOptions = {
61
- srcDir: "server",
62
- outDir: "types",
63
- outputFile: "appsscript.ts"
64
- };
65
- gasnukiOptions = {
66
- ...defaultOptions,
67
- ...fileConfig,
68
- ...options || {}
69
- };
57
+ async configResolved(config) {
58
+ projectRoot = config.root;
59
+ await reloadOptions();
70
60
  },
71
61
  async configureServer(server) {
72
- const targetDir = path__namespace.resolve(projectRoot, gasnukiOptions.srcDir);
73
- runGeneration("server startup");
74
- server.watcher.on("all", (_event, filePath) => {
62
+ server.watcher.on("all", async (_event, filePath) => {
63
+ const fileName = path__namespace.basename(filePath);
64
+ if (fileName.startsWith("gasnuki.config.")) {
65
+ consola.consola.info("[gasnuki] Config file changed, reloading...");
66
+ await reloadOptions();
67
+ runGeneration("config change");
68
+ return;
69
+ }
70
+ const targetDir = path__namespace.resolve(projectRoot, gasnukiOptions.srcDir);
75
71
  const relativePath = path__namespace.relative(targetDir, filePath);
76
72
  if (!relativePath.startsWith("..") && relativePath !== "..") {
77
73
  runGeneration(path__namespace.relative(projectRoot, filePath));
78
74
  }
79
75
  });
76
+ runGeneration("server startup");
80
77
  }
81
78
  };
79
+ async function reloadOptions() {
80
+ const fileConfig = await config.loadConfig(projectRoot);
81
+ const defaultOptions = {
82
+ srcDir: "server",
83
+ outDir: "types",
84
+ outputFile: "appsscript.ts"
85
+ };
86
+ gasnukiOptions = {
87
+ ...defaultOptions,
88
+ ...fileConfig,
89
+ ...options || {}
90
+ };
91
+ }
82
92
  }
83
93
 
84
94
  exports.gasnuki = gasnuki;
package/dist/vite.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as path from 'node:path';
2
2
  import { consola } from 'consola';
3
- import { l as loadConfig, g as generateAppsScriptTypes } from './shared/gasnuki.BAmTBfMa.mjs';
3
+ import { l as loadConfig, g as generateAppsScriptTypes } from './shared/gasnuki.36-kDBNB.mjs';
4
4
  import 'node:crypto';
5
5
  import 'node:fs';
6
6
  import 'ts-morph';
@@ -20,13 +20,13 @@ function gasnuki(options) {
20
20
  debounce(async () => {
21
21
  const reason = triggeredBy ? ` (triggered by: ${triggeredBy})` : "";
22
22
  console.log("");
23
- consola.info(`[gasnuki] Generating AppsScript types${reason}...`);
24
23
  try {
25
24
  await generateAppsScriptTypes({
26
25
  ...gasnukiOptions,
27
- project: projectRoot
26
+ project: projectRoot,
27
+ quiet: true
28
28
  });
29
- consola.success("[gasnuki] Type generation complete.");
29
+ consola.success(`[gasnuki] Generated AppsScript types${reason}.`);
30
30
  } catch (e) {
31
31
  consola.error(
32
32
  `[gasnuki] Type generation failed: ${e.message}`
@@ -40,29 +40,39 @@ function gasnuki(options) {
40
40
  // Apply only in serve mode
41
41
  async configResolved(config) {
42
42
  projectRoot = config.root;
43
- const fileConfig = await loadConfig(projectRoot);
44
- const defaultOptions = {
45
- srcDir: "server",
46
- outDir: "types",
47
- outputFile: "appsscript.ts"
48
- };
49
- gasnukiOptions = {
50
- ...defaultOptions,
51
- ...fileConfig,
52
- ...options || {}
53
- };
43
+ await reloadOptions();
54
44
  },
55
45
  async configureServer(server) {
56
- const targetDir = path.resolve(projectRoot, gasnukiOptions.srcDir);
57
- runGeneration("server startup");
58
- server.watcher.on("all", (_event, filePath) => {
46
+ server.watcher.on("all", async (_event, filePath) => {
47
+ const fileName = path.basename(filePath);
48
+ if (fileName.startsWith("gasnuki.config.")) {
49
+ consola.info("[gasnuki] Config file changed, reloading...");
50
+ await reloadOptions();
51
+ runGeneration("config change");
52
+ return;
53
+ }
54
+ const targetDir = path.resolve(projectRoot, gasnukiOptions.srcDir);
59
55
  const relativePath = path.relative(targetDir, filePath);
60
56
  if (!relativePath.startsWith("..") && relativePath !== "..") {
61
57
  runGeneration(path.relative(projectRoot, filePath));
62
58
  }
63
59
  });
60
+ runGeneration("server startup");
64
61
  }
65
62
  };
63
+ async function reloadOptions() {
64
+ const fileConfig = await loadConfig(projectRoot);
65
+ const defaultOptions = {
66
+ srcDir: "server",
67
+ outDir: "types",
68
+ outputFile: "appsscript.ts"
69
+ };
70
+ gasnukiOptions = {
71
+ ...defaultOptions,
72
+ ...fileConfig,
73
+ ...options || {}
74
+ };
75
+ }
66
76
  }
67
77
 
68
78
  export { gasnuki };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ciderjs/gasnuki",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "Type definitions and utilities for Google Apps Script client-side API",
5
5
  "main": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",