@gasboost/cli 0.1.0
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/LICENSE +21 -0
- package/README.md +166 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +23 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli/Cli.d.ts +7 -0
- package/dist/cli/Cli.d.ts.map +1 -0
- package/dist/cli/Cli.js +22 -0
- package/dist/cli/Cli.js.map +1 -0
- package/dist/cli/CommandRouter.d.ts +7 -0
- package/dist/cli/CommandRouter.d.ts.map +1 -0
- package/dist/cli/CommandRouter.js +19 -0
- package/dist/cli/CommandRouter.js.map +1 -0
- package/dist/config/GasboostConfig.d.ts +9 -0
- package/dist/config/GasboostConfig.d.ts.map +1 -0
- package/dist/config/GasboostConfig.js +4 -0
- package/dist/config/GasboostConfig.js.map +1 -0
- package/dist/config/GasboostConfigLoader.d.ts +12 -0
- package/dist/config/GasboostConfigLoader.d.ts.map +1 -0
- package/dist/config/GasboostConfigLoader.js +26 -0
- package/dist/config/GasboostConfigLoader.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/module/ModuleLoader.d.ts +7 -0
- package/dist/module/ModuleLoader.d.ts.map +1 -0
- package/dist/module/ModuleLoader.js +18 -0
- package/dist/module/ModuleLoader.js.map +1 -0
- package/dist/rtdb/RtdbRulesCommand.d.ts +15 -0
- package/dist/rtdb/RtdbRulesCommand.d.ts.map +1 -0
- package/dist/rtdb/RtdbRulesCommand.js +36 -0
- package/dist/rtdb/RtdbRulesCommand.js.map +1 -0
- package/dist/rtdb/RtdbRulesWriter.d.ts +10 -0
- package/dist/rtdb/RtdbRulesWriter.d.ts.map +1 -0
- package/dist/rtdb/RtdbRulesWriter.js +17 -0
- package/dist/rtdb/RtdbRulesWriter.js.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gasboost
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# @gasboost/cli
|
|
2
|
+
|
|
3
|
+
Gasboost エコシステム共通の開発CLIです。
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pnpm add -D @gasboost/cli
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## RTDB Security Rules
|
|
10
|
+
|
|
11
|
+
`@gasboost/realtime-firebase` で定義した Firebase Realtime Database の Security Rules を生成できます。
|
|
12
|
+
|
|
13
|
+
### Config
|
|
14
|
+
|
|
15
|
+
プロジェクトルートに `gasboost.config.ts` を作成します。
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { defineGasboostConfig } from "@gasboost/cli";
|
|
19
|
+
|
|
20
|
+
export default defineGasboostConfig({
|
|
21
|
+
rtdb: {
|
|
22
|
+
source: "./src/backend/lib/rtdb.ts",
|
|
23
|
+
out: "./database.rules.json",
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### RTDB definition
|
|
29
|
+
|
|
30
|
+
`source` で指定した module は `rtdb` を named export します。
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { FirebaseRtdb } from "@gasboost/realtime-firebase";
|
|
34
|
+
import { deals } from "@/database/deals";
|
|
35
|
+
import { dealSecurity } from "@/security/dealSecurity";
|
|
36
|
+
|
|
37
|
+
export const rtdb = FirebaseRtdb.generate({
|
|
38
|
+
tables: [deals] as const,
|
|
39
|
+
|
|
40
|
+
rowLevelSecurity: [dealSecurity],
|
|
41
|
+
|
|
42
|
+
principal: {
|
|
43
|
+
userId: "auth.uid",
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
CLI はこの module を実行し、export された `rtdb` の `rules()` を呼び出します。
|
|
49
|
+
|
|
50
|
+
### Generate
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
gasboost rtdb rules
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
成功すると、設定した `out` へ Security Rules が出力されます。
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
database.rules.json
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
例:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"rules": {
|
|
67
|
+
"deals": {
|
|
68
|
+
"...": "..."
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## TypeScript module loading
|
|
75
|
+
|
|
76
|
+
Gasboost CLI は application source の読み込みに `jiti` を利用します。
|
|
77
|
+
|
|
78
|
+
そのため、通常の Node.js native TypeScript execution に限定されず、プロジェクトの `tsconfig.json` に設定された `paths` も利用できます。
|
|
79
|
+
|
|
80
|
+
例えば次のような設定に対応します。
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"compilerOptions": {
|
|
85
|
+
"baseUrl": ".",
|
|
86
|
+
"paths": {
|
|
87
|
+
"@/*": ["./src/*"]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
application source 側では通常どおり利用できます。
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { deals } from "@/database/deals";
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Gasboost CLI を利用するためだけに import path を書き換える必要はありません。
|
|
100
|
+
|
|
101
|
+
## Architecture
|
|
102
|
+
|
|
103
|
+
```text
|
|
104
|
+
gasboost.config.ts
|
|
105
|
+
│
|
|
106
|
+
▼
|
|
107
|
+
GasboostConfigLoader
|
|
108
|
+
│
|
|
109
|
+
▼
|
|
110
|
+
ModuleLoader
|
|
111
|
+
jiti
|
|
112
|
+
│
|
|
113
|
+
▼
|
|
114
|
+
rtdb.source
|
|
115
|
+
│
|
|
116
|
+
▼
|
|
117
|
+
export const rtdb
|
|
118
|
+
│
|
|
119
|
+
▼
|
|
120
|
+
rtdb.rules()
|
|
121
|
+
│
|
|
122
|
+
▼
|
|
123
|
+
RtdbRulesWriter
|
|
124
|
+
│
|
|
125
|
+
▼
|
|
126
|
+
database.rules.json
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
`@gasboost/cli` は RLS や Firebase Security Rules のコンパイル処理を実装しません。
|
|
130
|
+
|
|
131
|
+
それらの責務は `@gasboost/realtime-firebase` にあります。
|
|
132
|
+
|
|
133
|
+
```text
|
|
134
|
+
@gasboost/realtime-firebase
|
|
135
|
+
├─ RLS -> authorization layout
|
|
136
|
+
├─ runtime path generation
|
|
137
|
+
├─ projectability validation
|
|
138
|
+
└─ Security Rules generation
|
|
139
|
+
|
|
140
|
+
@gasboost/cli
|
|
141
|
+
├─ config load
|
|
142
|
+
├─ TypeScript module load
|
|
143
|
+
├─ command routing
|
|
144
|
+
├─ filesystem output
|
|
145
|
+
├─ diagnostics
|
|
146
|
+
└─ exit code
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Commands
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
gasboost rtdb rules
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
現時点ではRTDB Security Rules生成のみを提供します。
|
|
156
|
+
|
|
157
|
+
今後、Gasboostエコシステム共通のdeveloper toolingを追加していきます。
|
|
158
|
+
|
|
159
|
+
## Requirements
|
|
160
|
+
|
|
161
|
+
- Node.js 24+
|
|
162
|
+
- pnpm
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
MIT
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Cli } from "./cli/Cli.js";
|
|
3
|
+
import { CommandRouter } from "./cli/CommandRouter.js";
|
|
4
|
+
import { GasboostConfigLoader } from "./config/GasboostConfigLoader.js";
|
|
5
|
+
import { ModuleLoader } from "./module/ModuleLoader.js";
|
|
6
|
+
import { RtdbRulesCommand } from "./rtdb/RtdbRulesCommand.js";
|
|
7
|
+
import { RtdbRulesWriter } from "./rtdb/RtdbRulesWriter.js";
|
|
8
|
+
const projectRoot = process.cwd();
|
|
9
|
+
const moduleLoader = new ModuleLoader(projectRoot);
|
|
10
|
+
const configLoader = new GasboostConfigLoader({
|
|
11
|
+
projectRoot,
|
|
12
|
+
moduleLoader,
|
|
13
|
+
});
|
|
14
|
+
const writer = new RtdbRulesWriter(projectRoot);
|
|
15
|
+
const rtdbRulesCommand = new RtdbRulesCommand({
|
|
16
|
+
configLoader,
|
|
17
|
+
moduleLoader,
|
|
18
|
+
writer,
|
|
19
|
+
});
|
|
20
|
+
const commandRouter = new CommandRouter(rtdbRulesCommand);
|
|
21
|
+
const cli = new Cli(commandRouter);
|
|
22
|
+
process.exitCode = await cli.run(process.argv.slice(2));
|
|
23
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAElC,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,WAAW,CAAC,CAAC;AAEnD,MAAM,YAAY,GAAG,IAAI,oBAAoB,CAAC;IAC5C,WAAW;IACX,YAAY;CACb,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,WAAW,CAAC,CAAC;AAEhD,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,CAAC;IAC5C,YAAY;IACZ,YAAY;IACZ,MAAM;CACP,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,gBAAgB,CAAC,CAAC;AAE1D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC;AAEnC,OAAO,CAAC,QAAQ,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cli.d.ts","sourceRoot":"","sources":["../../src/cli/Cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,qBAAa,GAAG;IACd,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAE9C,YAAmB,aAAa,EAAE,aAAa,EAE9C;IAEY,GAAG,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAczD;CACF"}
|
package/dist/cli/Cli.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class Cli {
|
|
2
|
+
commandRouter;
|
|
3
|
+
constructor(commandRouter) {
|
|
4
|
+
this.commandRouter = commandRouter;
|
|
5
|
+
}
|
|
6
|
+
async run(args) {
|
|
7
|
+
try {
|
|
8
|
+
await this.commandRouter.route(args);
|
|
9
|
+
return 0;
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
if (error instanceof Error) {
|
|
13
|
+
console.error(error.message);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
console.error(error);
|
|
17
|
+
}
|
|
18
|
+
return 1;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=Cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cli.js","sourceRoot":"","sources":["../../src/cli/Cli.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAG;IACG,aAAa,CAAgB;IAE9C,YAAmB,aAA4B;QAC7C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,IAAuB;QACtC,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAErC,OAAO,CAAC,CAAC;QACX,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;gBAC3B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC/B,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACvB,CAAC;YAED,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RtdbRulesCommand } from "../rtdb/RtdbRulesCommand.js";
|
|
2
|
+
export declare class CommandRouter {
|
|
3
|
+
private readonly rtdbRulesCommand;
|
|
4
|
+
constructor(rtdbRulesCommand: RtdbRulesCommand);
|
|
5
|
+
route(args: readonly string[]): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=CommandRouter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandRouter.d.ts","sourceRoot":"","sources":["../../src/cli/CommandRouter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;IAEpD,YAAmB,gBAAgB,EAAE,gBAAgB,EAEpD;IAEY,KAAK,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBzD;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class CommandRouter {
|
|
2
|
+
rtdbRulesCommand;
|
|
3
|
+
constructor(rtdbRulesCommand) {
|
|
4
|
+
this.rtdbRulesCommand = rtdbRulesCommand;
|
|
5
|
+
}
|
|
6
|
+
async route(args) {
|
|
7
|
+
if (args.length === 0 || args[0] === "--help" || args[0] === "-h") {
|
|
8
|
+
console.log(["Usage:", " gasboost rtdb rules"].join("\n"));
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (args[0] === "rtdb" && args[1] === "rules" && args.length === 2) {
|
|
12
|
+
const outputPath = await this.rtdbRulesCommand.execute();
|
|
13
|
+
console.log(`Firebase RTDB Security Rules generated: ${outputPath}`);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
throw new Error(`Unknown command: ${args.join(" ")}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=CommandRouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandRouter.js","sourceRoot":"","sources":["../../src/cli/CommandRouter.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,aAAa;IACP,gBAAgB,CAAmB;IAEpD,YAAmB,gBAAkC;QACnD,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,CAAC;IAEM,KAAK,CAAC,KAAK,CAAC,IAAuB;QACxC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YAClE,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAE5D,OAAO;QACT,CAAC;QAED,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnE,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;YAEzD,OAAO,CAAC,GAAG,CAAC,2CAA2C,UAAU,EAAE,CAAC,CAAC;YAErE,OAAO;QACT,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACxD,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type GasboostRtdbConfig = {
|
|
2
|
+
readonly source: string;
|
|
3
|
+
readonly out: string;
|
|
4
|
+
};
|
|
5
|
+
export type GasboostConfig = {
|
|
6
|
+
readonly rtdb?: GasboostRtdbConfig;
|
|
7
|
+
};
|
|
8
|
+
export declare function defineGasboostConfig(config: GasboostConfig): GasboostConfig;
|
|
9
|
+
//# sourceMappingURL=GasboostConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GasboostConfig.d.ts","sourceRoot":"","sources":["../../src/config/GasboostConfig.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,kBAAkB,CAAC;CACpC,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,cAAc,CAE3E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GasboostConfig.js","sourceRoot":"","sources":["../../src/config/GasboostConfig.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,oBAAoB,CAAC,MAAsB;IACzD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ModuleLoader } from "../module/ModuleLoader.js";
|
|
2
|
+
import type { GasboostConfig } from "./GasboostConfig.js";
|
|
3
|
+
export declare class GasboostConfigLoader {
|
|
4
|
+
private readonly projectRoot;
|
|
5
|
+
private readonly moduleLoader;
|
|
6
|
+
constructor({ projectRoot, moduleLoader, }: {
|
|
7
|
+
projectRoot: string;
|
|
8
|
+
moduleLoader: ModuleLoader;
|
|
9
|
+
});
|
|
10
|
+
load(): Promise<GasboostConfig>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=GasboostConfigLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GasboostConfigLoader.d.ts","sourceRoot":"","sources":["../../src/config/GasboostConfigLoader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAErC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAE5C,YAAmB,EACjB,WAAW,EACX,YAAY,GACb,EAAE;QACD,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,YAAY,CAAC;KAC5B,EAGA;IAEY,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,CAsB3C;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { access } from "node:fs/promises";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
export class GasboostConfigLoader {
|
|
4
|
+
projectRoot;
|
|
5
|
+
moduleLoader;
|
|
6
|
+
constructor({ projectRoot, moduleLoader, }) {
|
|
7
|
+
this.projectRoot = projectRoot;
|
|
8
|
+
this.moduleLoader = moduleLoader;
|
|
9
|
+
}
|
|
10
|
+
async load() {
|
|
11
|
+
const configPath = resolve(this.projectRoot, "gasboost.config.ts");
|
|
12
|
+
try {
|
|
13
|
+
await access(configPath);
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
throw new Error(`Gasboost config was not found: ${configPath}`);
|
|
17
|
+
}
|
|
18
|
+
const configModule = await this.moduleLoader.import("gasboost.config.ts");
|
|
19
|
+
const config = configModule.default;
|
|
20
|
+
if (typeof config !== "object" || config === null) {
|
|
21
|
+
throw new Error("gasboost.config.ts must export a Gasboost config as the default export.");
|
|
22
|
+
}
|
|
23
|
+
return config;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=GasboostConfigLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GasboostConfigLoader.js","sourceRoot":"","sources":["../../src/config/GasboostConfigLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,MAAM,OAAO,oBAAoB;IACd,WAAW,CAAS;IAEpB,YAAY,CAAe;IAE5C,YAAmB,EACjB,WAAW,EACX,YAAY,GAIb;QACC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC;QAEnE,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;QAC3B,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,kCAAkC,UAAU,EAAE,CAAC,CAAC;QAClE,CAAC;QAED,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAEhD,oBAAoB,CAAC,CAAC;QAEzB,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC;QAEpC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CACb,yEAAyE,CAC1E,CAAC;QACJ,CAAC;QAED,OAAO,MAAwB,CAAC;IAClC,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,kBAAkB,GACxB,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,GAGrB,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModuleLoader.d.ts","sourceRoot":"","sources":["../../src/module/ModuleLoader.ts"],"names":[],"mappings":"AAIA,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAErC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAgC;IAErD,YAAmB,WAAW,EAAE,MAAM,EASrC;IAEY,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAI9D;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createJiti } from "jiti";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
export class ModuleLoader {
|
|
5
|
+
projectRoot;
|
|
6
|
+
jiti;
|
|
7
|
+
constructor(projectRoot) {
|
|
8
|
+
this.projectRoot = projectRoot;
|
|
9
|
+
this.jiti = createJiti(pathToFileURL(resolve(projectRoot, "gasboost.config.ts")).href, {
|
|
10
|
+
tsconfigPaths: true,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
async import(path) {
|
|
14
|
+
const modulePath = resolve(this.projectRoot, path);
|
|
15
|
+
return (await this.jiti.import(modulePath));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ModuleLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModuleLoader.js","sourceRoot":"","sources":["../../src/module/ModuleLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,OAAO,YAAY;IACN,WAAW,CAAS;IAEpB,IAAI,CAAgC;IAErD,YAAmB,WAAmB;QACpC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE/B,IAAI,CAAC,IAAI,GAAG,UAAU,CACpB,aAAa,CAAC,OAAO,CAAC,WAAW,EAAE,oBAAoB,CAAC,CAAC,CAAC,IAAI,EAC9D;YACE,aAAa,EAAE,IAAI;SACpB,CACF,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,MAAM,CAAmB,IAAY;QAChD,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QAEnD,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAM,CAAC;IACnD,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { GasboostConfigLoader } from "../config/GasboostConfigLoader.js";
|
|
2
|
+
import type { ModuleLoader } from "../module/ModuleLoader.js";
|
|
3
|
+
import type { RtdbRulesWriter } from "./RtdbRulesWriter.js";
|
|
4
|
+
export declare class RtdbRulesCommand {
|
|
5
|
+
private readonly configLoader;
|
|
6
|
+
private readonly moduleLoader;
|
|
7
|
+
private readonly writer;
|
|
8
|
+
constructor({ configLoader, moduleLoader, writer, }: {
|
|
9
|
+
configLoader: GasboostConfigLoader;
|
|
10
|
+
moduleLoader: ModuleLoader;
|
|
11
|
+
writer: RtdbRulesWriter;
|
|
12
|
+
});
|
|
13
|
+
execute(): Promise<string>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=RtdbRulesCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RtdbRulesCommand.d.ts","sourceRoot":"","sources":["../../src/rtdb/RtdbRulesCommand.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAU5D,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAuB;IAEpD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAE5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IAEzC,YAAmB,EACjB,YAAY,EACZ,YAAY,EACZ,MAAM,GACP,EAAE;QACD,YAAY,EAAE,oBAAoB,CAAC;QACnC,YAAY,EAAE,YAAY,CAAC;QAC3B,MAAM,EAAE,eAAe,CAAC;KACzB,EAIA;IAEY,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,CAwCtC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export class RtdbRulesCommand {
|
|
2
|
+
configLoader;
|
|
3
|
+
moduleLoader;
|
|
4
|
+
writer;
|
|
5
|
+
constructor({ configLoader, moduleLoader, writer, }) {
|
|
6
|
+
this.configLoader = configLoader;
|
|
7
|
+
this.moduleLoader = moduleLoader;
|
|
8
|
+
this.writer = writer;
|
|
9
|
+
}
|
|
10
|
+
async execute() {
|
|
11
|
+
const config = await this.configLoader.load();
|
|
12
|
+
if (config.rtdb === undefined) {
|
|
13
|
+
throw new Error("RTDB configuration was not found in gasboost.config.ts.");
|
|
14
|
+
}
|
|
15
|
+
if (config.rtdb.source.length === 0) {
|
|
16
|
+
throw new Error("rtdb.source must not be empty.");
|
|
17
|
+
}
|
|
18
|
+
if (config.rtdb.out.length === 0) {
|
|
19
|
+
throw new Error("rtdb.out must not be empty.");
|
|
20
|
+
}
|
|
21
|
+
const source = await this.moduleLoader.import(config.rtdb.source);
|
|
22
|
+
if (typeof source.rtdb !== "object" ||
|
|
23
|
+
source.rtdb === null ||
|
|
24
|
+
!("rules" in source.rtdb) ||
|
|
25
|
+
typeof source.rtdb.rules !== "function") {
|
|
26
|
+
throw new Error(`RTDB source '${config.rtdb.source}' must export 'rtdb' with a rules() method.`);
|
|
27
|
+
}
|
|
28
|
+
const rtdb = source.rtdb;
|
|
29
|
+
const rules = rtdb.rules();
|
|
30
|
+
return this.writer.write({
|
|
31
|
+
out: config.rtdb.out,
|
|
32
|
+
rules,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=RtdbRulesCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RtdbRulesCommand.js","sourceRoot":"","sources":["../../src/rtdb/RtdbRulesCommand.ts"],"names":[],"mappings":"AAaA,MAAM,OAAO,gBAAgB;IACV,YAAY,CAAuB;IAEnC,YAAY,CAAe;IAE3B,MAAM,CAAkB;IAEzC,YAAmB,EACjB,YAAY,EACZ,YAAY,EACZ,MAAM,GAKP;QACC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;QAE9C,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACb,yDAAyD,CAC1D,CAAC;QACJ,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAC3C,MAAM,CAAC,IAAI,CAAC,MAAM,CACnB,CAAC;QAEF,IACE,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ;YAC/B,MAAM,CAAC,IAAI,KAAK,IAAI;YACpB,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC;YACzB,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,UAAU,EACvC,CAAC;YACD,MAAM,IAAI,KAAK,CACb,gBAAgB,MAAM,CAAC,IAAI,CAAC,MAAM,6CAA6C,CAChF,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,CAAC,IAAsB,CAAC;QAE3C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAE3B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;YACvB,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;YACpB,KAAK;SACN,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FirebaseRtdbRulesJson } from "@gasboost/realtime-firebase";
|
|
2
|
+
export declare class RtdbRulesWriter {
|
|
3
|
+
private readonly projectRoot;
|
|
4
|
+
constructor(projectRoot: string);
|
|
5
|
+
write({ out, rules, }: {
|
|
6
|
+
out: string;
|
|
7
|
+
rules: FirebaseRtdbRulesJson;
|
|
8
|
+
}): Promise<string>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=RtdbRulesWriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RtdbRulesWriter.d.ts","sourceRoot":"","sources":["../../src/rtdb/RtdbRulesWriter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAIzE,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IAErC,YAAmB,WAAW,EAAE,MAAM,EAErC;IAEY,KAAK,CAAC,EACjB,GAAG,EACH,KAAK,GACN,EAAE;QACD,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,qBAAqB,CAAC;KAC9B,GAAG,OAAO,CAAC,MAAM,CAAC,CAUlB;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
export class RtdbRulesWriter {
|
|
4
|
+
projectRoot;
|
|
5
|
+
constructor(projectRoot) {
|
|
6
|
+
this.projectRoot = projectRoot;
|
|
7
|
+
}
|
|
8
|
+
async write({ out, rules, }) {
|
|
9
|
+
const outputPath = resolve(this.projectRoot, out);
|
|
10
|
+
await mkdir(dirname(outputPath), {
|
|
11
|
+
recursive: true,
|
|
12
|
+
});
|
|
13
|
+
await writeFile(outputPath, `${JSON.stringify(rules, null, 2)}\n`, "utf8");
|
|
14
|
+
return outputPath;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=RtdbRulesWriter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RtdbRulesWriter.js","sourceRoot":"","sources":["../../src/rtdb/RtdbRulesWriter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,OAAO,eAAe;IACT,WAAW,CAAS;IAErC,YAAmB,WAAmB;QACpC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,KAAK,CAAC,EACjB,GAAG,EACH,KAAK,GAIN;QACC,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;QAElD,MAAM,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC/B,SAAS,EAAE,IAAI;SAChB,CAAC,CAAC;QAEH,MAAM,SAAS,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAE3E,OAAO,UAAU,CAAC;IACpB,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gasboost/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Developer tooling for the Gasboost ecosystem",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"gasboost": "./dist/bin.js"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=24"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"jiti": "^2.7.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@gasboost/realtime-firebase": "^0.1.0",
|
|
28
|
+
"@types/node": "^24.13.4",
|
|
29
|
+
"typescript": "^7.0.2",
|
|
30
|
+
"vitest": "^5.0.0"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"google-apps-script",
|
|
34
|
+
"gas",
|
|
35
|
+
"firebase",
|
|
36
|
+
"realtime-database",
|
|
37
|
+
"cli",
|
|
38
|
+
"gasboost"
|
|
39
|
+
],
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"scripts": {
|
|
42
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"test:e2e": "pnpm build && vitest run tests/Cli.e2e.spec.ts --config vitest.e2e.config.ts",
|
|
45
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
46
|
+
"pack:check": "pnpm pack --dry-run"
|
|
47
|
+
}
|
|
48
|
+
}
|