effing-cloud 0.1.1 → 0.2.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/dist/cli.js +3 -20
- package/dist/index.d.ts +22 -0
- package/dist/index.js +20 -0
- package/package.json +12 -2
- package/dist/cli.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -1,21 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { Command } from "commander";
|
|
6
|
-
|
|
7
|
-
// src/commands/login.ts
|
|
8
|
-
function registerLogin(program2) {
|
|
9
|
-
program2.command("login").description("Authenticate with effing-cloud").action(() => {
|
|
10
|
-
console.log("Login is not yet implemented.");
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// src/cli.ts
|
|
15
|
-
var require2 = createRequire(import.meta.url);
|
|
16
|
-
var { version } = require2("../package.json");
|
|
17
|
-
var program = new Command();
|
|
18
|
-
program.name("effing-cloud").description("CLI for the effing-cloud platform").version(version);
|
|
19
|
-
registerLogin(program);
|
|
20
|
-
program.parse();
|
|
21
|
-
//# sourceMappingURL=cli.js.map
|
|
2
|
+
import{createRequire as U}from"module";import{Command as K}from"commander";function w(t){t.command("login").description("Authenticate with Effing Cloud").action(()=>{console.log("Login is not yet implemented.")})}import u from"process";import d from"path";import y from"fs";import{pathToFileURL as S}from"url";import{randomBytes as D}from"crypto";import{build as F}from"esbuild";import{z as g}from"zod";var h=g.union([g.string(),g.array(g.string())]),L=g.object({project:g.string().min(1),images:h.optional(),annies:h.optional(),effies:h.optional()});var P=["effing-cloud.config.ts","effing-cloud.config.mts","effing-cloud.config.js"];function v(t,n){if(n){let i=d.isAbsolute(n)?n:d.resolve(t,n);if(!y.existsSync(i))throw new Error(`Config file not found: ${i}`);return i}for(let i of P){let e=d.resolve(t,i);if(y.existsSync(e))return e}throw new Error(`No effing-cloud.config.ts found in ${t}. Create one with \`export default defineConfig({ project: "...", ... })\` or pass --config <path>.`)}function A(){return{name:"effing-cloud-stub",setup(t){t.onResolve({filter:/^effing-cloud$/},n=>({path:n.path,namespace:"effing-cloud-stub"})),t.onLoad({filter:/.*/,namespace:"effing-cloud-stub"},()=>({contents:"export const defineConfig = (c) => c;",loader:"js"}))}}}async function C(t,n){let i=v(t,n),e=d.dirname(i),a=d.join(e,`.effing-cloud.config.${D(4).toString("hex")}.mjs`);try{await F({entryPoints:[i],outfile:a,bundle:!0,format:"esm",platform:"node",target:"node22",packages:"external",plugins:[A()],logLevel:"silent"});let r=await import(S(a).href),o=L.safeParse(r.default);if(!o.success)throw new Error(`Invalid config in ${i}:
|
|
3
|
+
${o.error.message}`);return{config:o.data,configPath:i,configDir:e}}finally{await y.promises.unlink(a).catch(()=>{})}}import $ from"path";import{build as j}from"esbuild";import{glob as N}from"tinyglobby";var R={image:"images",annie:"annies",effie:"effies"};async function E(t){let{configDir:n,config:i}=t,e={image:await b(n,i.images),annie:await b(n,i.annies),effie:await b(n,i.effies)};if(e.image.length+e.annie.length+e.effie.length===0)throw new Error(`No modules matched the globs in the config. Set images/annies/effies to paths that exist relative to ${n}.`);let r=B(e),o=await j({stdin:{contents:r,resolveDir:n,loader:"ts",sourcefile:"effing-entry.ts"},bundle:!0,format:"esm",platform:"node",target:"node22",external:["node:*","@napi-rs/canvas","@effing/fn"],write:!1,logLevel:"silent"});if(o.outputFiles.length!==1)throw new Error(`esbuild produced ${o.outputFiles.length} output files; expected 1`);let s=o.outputFiles[0].contents,p=new ArrayBuffer(s.byteLength),l=new Uint8Array(p);l.set(s);let c={modules:{image:e.image.map(f=>f.id),annie:e.annie.map(f=>f.id),effie:e.effie.map(f=>f.id)}};return{bundle:l,manifest:c}}async function b(t,n){if(!n)return[];let i=Array.isArray(n)?n:[n],e=await N(i,{cwd:t,absolute:!0}),a=new Map;for(let r of e){let o=$.basename(r,$.extname(r)),s=a.get(o);if(s&&s!==r)throw new Error(`Duplicate module id "${o}" \u2014 matched by both ${s} and ${r}. Module ids must be unique per kind.`);a.set(o,r)}return[...a.entries()].map(([r,o])=>({id:r,absPath:o})).sort((r,o)=>r.id.localeCompare(o.id))}function B(t){let n=[],i=(e,a)=>`_${e}_${a}`;for(let e of["image","annie","effie"])t[e].forEach((a,r)=>{let o=i(e,r);n.push(`import { propsSchema as ${o}_ps, previewProps as ${o}_pp, runner as ${o}_r } from ${JSON.stringify(a.absPath)};`)});for(let e of["image","annie","effie"]){let a=R[e];n.push(`export const ${a} = {`),t[e].forEach((r,o)=>{let s=i(e,o);n.push(` ${JSON.stringify(r.id)}: { propsSchema: ${s}_ps, previewProps: ${s}_pp, runner: ${s}_r },`)}),n.push("};")}return n.join(`
|
|
4
|
+
`)}var I="https://fn.effing.dev";function x(t){t.command("deploy").description("Bundle and deploy your @effing/fn functions to Effing Cloud").option("-c, --config <path>","path to the effing-cloud.config.ts file").option("--dry-run","bundle without uploading \u2014 prints the manifest and bundle size",!1).action(async n=>{try{await O(n)}catch(i){console.error(i.message),u.exitCode=1}})}async function O(t){let n=u.env.EFFING_CLOUD_API_KEY;if(!t.dryRun&&!n)throw new Error("EFFING_CLOUD_API_KEY is not set. Export your API key or pass --dry-run to bundle without uploading.");let i=(u.env.EFFING_CLOUD_FN_BASE_URL??I).replace(/\/$/,""),{config:e,configDir:a,configPath:r}=await C(u.cwd(),t.config);console.log(`Loaded config from ${r}`);let{bundle:o,manifest:s}=await E({configDir:a,config:e}),p=s.modules.image.length+s.modules.annie.length+s.modules.effie.length;if(console.log(`Bundled ${p} module(s) \u2014 image: ${s.modules.image.length}, annie: ${s.modules.annie.length}, effie: ${s.modules.effie.length} (${o.byteLength} bytes)`),t.dryRun){console.log("Dry run \u2014 skipping upload. Manifest:"),console.log(JSON.stringify(s,null,2));return}let l=new FormData;l.append("projectSlug",e.project),l.append("manifest",JSON.stringify(s)),l.append("bundle",new Blob([o],{type:"application/javascript"}),"bundle.js");let c=await fetch(`${i}/-/deploy`,{method:"POST",headers:{Authorization:`Bearer ${n}`},body:l});if(c.status!==201){let _=await c.text();throw new Error(`Deploy failed \u2014 ${c.status} ${c.statusText}: ${_}`)}let f=await c.json();console.log(`Deployed ${e.project} \u2014 version ${f.version}, deployment ${f.deploymentId}, hash ${f.bundleHash}, ${f.bundleSize} bytes`)}var k=U(import.meta.url),{version:z}=k("../package.json"),m=new K;m.name("effing-cloud").description("CLI for the Effing Cloud platform").version(z);w(m);x(m);m.parse();
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const effingCloudConfigSchema: z.ZodObject<{
|
|
4
|
+
project: z.ZodString;
|
|
5
|
+
images: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
6
|
+
annies: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
7
|
+
effies: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
project: string;
|
|
10
|
+
images?: string | string[] | undefined;
|
|
11
|
+
annies?: string | string[] | undefined;
|
|
12
|
+
effies?: string | string[] | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
project: string;
|
|
15
|
+
images?: string | string[] | undefined;
|
|
16
|
+
annies?: string | string[] | undefined;
|
|
17
|
+
effies?: string | string[] | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
type EffingCloudConfig = z.infer<typeof effingCloudConfigSchema>;
|
|
20
|
+
declare function defineConfig(config: EffingCloudConfig): EffingCloudConfig;
|
|
21
|
+
|
|
22
|
+
export { type EffingCloudConfig, defineConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/config.ts
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import { pathToFileURL } from "url";
|
|
5
|
+
import { randomBytes } from "crypto";
|
|
6
|
+
import { build } from "esbuild";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
var globField = z.union([z.string(), z.array(z.string())]);
|
|
9
|
+
var effingCloudConfigSchema = z.object({
|
|
10
|
+
project: z.string().min(1),
|
|
11
|
+
images: globField.optional(),
|
|
12
|
+
annies: globField.optional(),
|
|
13
|
+
effies: globField.optional()
|
|
14
|
+
});
|
|
15
|
+
function defineConfig(config) {
|
|
16
|
+
return config;
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
defineConfig
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effing-cloud",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"effing-cloud": "dist/cli.js"
|
|
8
8
|
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
9
16
|
"files": [
|
|
10
17
|
"dist"
|
|
11
18
|
],
|
|
@@ -13,7 +20,10 @@
|
|
|
13
20
|
"access": "public"
|
|
14
21
|
},
|
|
15
22
|
"dependencies": {
|
|
16
|
-
"commander": "^13.0.0"
|
|
23
|
+
"commander": "^13.0.0",
|
|
24
|
+
"esbuild": "^0.28.0",
|
|
25
|
+
"tinyglobby": "^0.2.15",
|
|
26
|
+
"zod": "^3.25.76"
|
|
17
27
|
},
|
|
18
28
|
"devDependencies": {
|
|
19
29
|
"tsup": "^8.0.0",
|
package/dist/cli.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/commands/login.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { Command } from \"commander\";\nimport { registerLogin } from \"./commands/login.js\";\n\nconst require = createRequire(import.meta.url);\nconst { version } = require(\"../package.json\");\n\nconst program = new Command();\n\nprogram.name(\"effing-cloud\").description(\"CLI for the effing-cloud platform\").version(version);\n\nregisterLogin(program);\n\nprogram.parse();\n","import type { Command } from \"commander\";\n\nexport function registerLogin(program: Command) {\n program\n .command(\"login\")\n .description(\"Authenticate with effing-cloud\")\n .action(() => {\n console.log(\"Login is not yet implemented.\");\n });\n}\n"],"mappings":";;;AAAA,SAAS,qBAAqB;AAC9B,SAAS,eAAe;;;ACCjB,SAAS,cAAcA,UAAkB;AAC9C,EAAAA,SACG,QAAQ,OAAO,EACf,YAAY,gCAAgC,EAC5C,OAAO,MAAM;AACZ,YAAQ,IAAI,+BAA+B;AAAA,EAC7C,CAAC;AACL;;;ADLA,IAAMC,WAAU,cAAc,YAAY,GAAG;AAC7C,IAAM,EAAE,QAAQ,IAAIA,SAAQ,iBAAiB;AAE7C,IAAM,UAAU,IAAI,QAAQ;AAE5B,QAAQ,KAAK,cAAc,EAAE,YAAY,mCAAmC,EAAE,QAAQ,OAAO;AAE7F,cAAc,OAAO;AAErB,QAAQ,MAAM;","names":["program","require"]}
|