@notation/cli 0.5.0 → 0.6.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/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ async function compile(entryPoint, watch2 = false) {
|
|
|
17
17
|
log(`${watch2 ? "Watching" : "Compiling"} infrastructure`, entryPoint);
|
|
18
18
|
await compileInfra(entryPoint, watch2);
|
|
19
19
|
log(`${watch2 ? "Watching" : "Compiling"} functions`);
|
|
20
|
-
const fnEntryPoints = await glob("
|
|
20
|
+
const fnEntryPoints = await glob("runtime/**/*.fn.ts");
|
|
21
21
|
let disposeFnCompiler = await compileFns(fnEntryPoints, watch2);
|
|
22
22
|
if (!watch2)
|
|
23
23
|
return;
|
|
@@ -27,7 +27,7 @@ async function compile(entryPoint, watch2 = false) {
|
|
|
27
27
|
}).on("all", async () => {
|
|
28
28
|
if (disposeFnCompiler)
|
|
29
29
|
disposeFnCompiler();
|
|
30
|
-
const fnEntryPoints2 = await glob("
|
|
30
|
+
const fnEntryPoints2 = await glob("runtime/**/*.fn.ts");
|
|
31
31
|
disposeFnCompiler = await compileFns(fnEntryPoints2, watch2);
|
|
32
32
|
});
|
|
33
33
|
}
|
|
@@ -35,7 +35,7 @@ async function compileInfra(entryPoint, watch2 = false) {
|
|
|
35
35
|
const context = await esbuild.context({
|
|
36
36
|
entryPoints: [entryPoint],
|
|
37
37
|
plugins: [functionInfraPlugin()],
|
|
38
|
-
outdir: "dist
|
|
38
|
+
outdir: "dist",
|
|
39
39
|
outbase: ".",
|
|
40
40
|
outExtension: { ".js": ".mjs" },
|
|
41
41
|
bundle: true,
|
|
@@ -150,80 +150,13 @@ async function watch(entryPoint) {
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
// src/scaffold.ts
|
|
154
|
-
import path from "node:path";
|
|
155
|
-
import fse from "fs-extra";
|
|
156
|
-
import { execSync } from "node:child_process";
|
|
157
|
-
import whichPmRuns from "which-pm-runs";
|
|
158
|
-
var dirname = path.dirname(new URL(import.meta.url).pathname);
|
|
159
|
-
var packageManager = whichPmRuns()?.name || "npm";
|
|
160
|
-
var packageManagerInstallCommand = getPmInstallCommand(packageManager);
|
|
161
|
-
async function scaffoldApp(appName) {
|
|
162
|
-
const cwd = process.cwd();
|
|
163
|
-
const appDir = path.join(cwd, appName);
|
|
164
|
-
await fse.ensureDir(appDir);
|
|
165
|
-
const children = await fse.readdir(appDir);
|
|
166
|
-
if (children.length) {
|
|
167
|
-
console.error(
|
|
168
|
-
`Directory ${path.relative(process.cwd(), appDir)} is not empty`
|
|
169
|
-
);
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
console.log(`
|
|
173
|
-
Creating app from template...`);
|
|
174
|
-
const templateDir = path.join(dirname, "../templates/starter");
|
|
175
|
-
await fse.copy(templateDir, appDir);
|
|
176
|
-
const packageJsonPath = path.join(appDir, "package.json");
|
|
177
|
-
const packageJsonContent = await fse.readFile(packageJsonPath, "utf8");
|
|
178
|
-
const packageJson = JSON.parse(packageJsonContent);
|
|
179
|
-
packageJson.name = appName;
|
|
180
|
-
const updatedPackageJson = JSON.stringify(packageJson, null, 2);
|
|
181
|
-
await fse.writeFile(packageJsonPath, updatedPackageJson, {
|
|
182
|
-
encoding: "utf8"
|
|
183
|
-
});
|
|
184
|
-
console.log(`Installing dependencies with ${packageManager}...`);
|
|
185
|
-
execSync(`${packageManagerInstallCommand} @notation/cli @notation/aws`, {
|
|
186
|
-
cwd: appDir,
|
|
187
|
-
stdio: "inherit"
|
|
188
|
-
});
|
|
189
|
-
console.log("\nApp ready! To get started run:\n");
|
|
190
|
-
console.log(`\u279C cd ${appName}`);
|
|
191
|
-
console.log(`\u279C ${getPmRunCommand(packageManager)} viz`);
|
|
192
|
-
}
|
|
193
|
-
function getPmInstallCommand(pm) {
|
|
194
|
-
switch (pm) {
|
|
195
|
-
case "yarn":
|
|
196
|
-
return "yarn add";
|
|
197
|
-
case "pnpm":
|
|
198
|
-
return "pnpm add";
|
|
199
|
-
case "bun":
|
|
200
|
-
return "bun add";
|
|
201
|
-
default:
|
|
202
|
-
return "npm install";
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
function getPmRunCommand(pm) {
|
|
206
|
-
switch (pm) {
|
|
207
|
-
case "yarn":
|
|
208
|
-
return "yarn";
|
|
209
|
-
case "pnpm":
|
|
210
|
-
return "pnpm";
|
|
211
|
-
case "bun":
|
|
212
|
-
return "bun";
|
|
213
|
-
default:
|
|
214
|
-
return "npm run";
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
153
|
// src/index.ts
|
|
219
|
-
|
|
220
|
-
await scaffoldApp(appName);
|
|
221
|
-
});
|
|
154
|
+
import { startDashboardServer } from "@notation/dashboard";
|
|
222
155
|
program.command("compile").argument("<entryPoint>", "entryPoint").description("Compile Notation App").action(async (entryPoint) => {
|
|
223
156
|
await compile(entryPoint);
|
|
224
157
|
});
|
|
225
|
-
program.command("
|
|
226
|
-
await
|
|
158
|
+
program.command("dashboard").description("Start Notation Dashboard").action(async () => {
|
|
159
|
+
await startDashboardServer();
|
|
227
160
|
});
|
|
228
161
|
program.command("deploy").argument("<entryPoint>", "entryPoint").description("Deploy Notation App").action(async (entryPoint) => {
|
|
229
162
|
await deploy(entryPoint);
|
|
@@ -231,6 +164,9 @@ program.command("deploy").argument("<entryPoint>", "entryPoint").description("De
|
|
|
231
164
|
program.command("destroy").argument("<entryPoint>", "entryPoint").description("Destroy Notation App").action(async (entryPoint) => {
|
|
232
165
|
await destroy(entryPoint);
|
|
233
166
|
});
|
|
167
|
+
program.command("viz").argument("<entryPoint>", "entryPoint").description("Visualise Notation App").action(async (entryPoint) => {
|
|
168
|
+
await visualise(entryPoint);
|
|
169
|
+
});
|
|
234
170
|
program.command("watch").argument("<entryPoint>", "entryPoint").description("Watch Notation App").action(async (entryPoint) => {
|
|
235
171
|
await watch(entryPoint);
|
|
236
172
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@notation/cli",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.1",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
7
|
"templates"
|
|
@@ -13,18 +13,16 @@
|
|
|
13
13
|
"chokidar": "^3.5.3",
|
|
14
14
|
"commander": "^11.0.0",
|
|
15
15
|
"esbuild": "^0.19.3",
|
|
16
|
-
"fs-extra": "^11.1.1",
|
|
17
16
|
"glob": "^10.3.10",
|
|
18
|
-
"
|
|
19
|
-
"@notation/
|
|
20
|
-
"@notation/
|
|
17
|
+
"@notation/core": "0.5.0",
|
|
18
|
+
"@notation/esbuild-plugins": "0.4.1",
|
|
19
|
+
"@notation/dashboard": "0.2.0"
|
|
21
20
|
},
|
|
22
21
|
"devDependencies": {
|
|
23
|
-
"@types/fs-extra": "^11.0.4",
|
|
24
22
|
"@types/which-pm-runs": "^1.0.2"
|
|
25
23
|
},
|
|
26
24
|
"scripts": {
|
|
27
|
-
"build": "tsup",
|
|
28
|
-
"dev": "
|
|
25
|
+
"build": "tsup --clean",
|
|
26
|
+
"dev": "tsup --watch"
|
|
29
27
|
}
|
|
30
28
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { api, router } from "@notation/aws/api-gateway";
|
|
2
|
-
import { getTodos, getTodoCount } from "./todos/todos.fn";
|
|
3
|
-
|
|
4
|
-
const todoApi = api({ name: "todo-api" });
|
|
5
|
-
const todoRouter = router(todoApi);
|
|
6
|
-
|
|
7
|
-
todoRouter.get("/todos", getTodos);
|
|
8
|
-
todoRouter.get("/todos/count", getTodoCount);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { LambdaConfig } from "@notation/aws/lambda.fn";
|
|
2
|
-
import { handle, json } from "@notation/aws/lambda.fn";
|
|
3
|
-
import { api } from "./utils";
|
|
4
|
-
|
|
5
|
-
const todos = await api.get<any[]>("/todos");
|
|
6
|
-
|
|
7
|
-
export const getTodos = handle.apiRequest(() => {
|
|
8
|
-
return json(todos);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
export const getTodoCount = handle.apiRequest(() => {
|
|
12
|
-
return json(todos.length);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export const config: LambdaConfig = {
|
|
16
|
-
service: "aws/lambda",
|
|
17
|
-
timeout: 5,
|
|
18
|
-
memory: 64,
|
|
19
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"display": "Default",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"lib": ["esnext"],
|
|
6
|
-
"module": "esnext",
|
|
7
|
-
"target": "esnext",
|
|
8
|
-
|
|
9
|
-
"moduleResolution": "bundler",
|
|
10
|
-
"noEmit": true,
|
|
11
|
-
|
|
12
|
-
"composite": false,
|
|
13
|
-
"declaration": true,
|
|
14
|
-
"declarationMap": true,
|
|
15
|
-
"forceConsistentCasingInFileNames": true,
|
|
16
|
-
"inlineSources": false,
|
|
17
|
-
"isolatedModules": true,
|
|
18
|
-
"noUnusedLocals": false,
|
|
19
|
-
"noUnusedParameters": false,
|
|
20
|
-
"preserveWatchOutput": true,
|
|
21
|
-
"skipDefaultLibCheck": true,
|
|
22
|
-
"skipLibCheck": true,
|
|
23
|
-
"strict": true,
|
|
24
|
-
"strictNullChecks": true
|
|
25
|
-
},
|
|
26
|
-
"exclude": ["node_modules"]
|
|
27
|
-
}
|