@dual-os/cli 0.0.0-stage → 0.11.0-next.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 +4 -0
- package/README.md +15 -2
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/auth/credentials.d.ts +17 -0
- package/dist/auth/credentials.d.ts.map +1 -0
- package/dist/auth/credentials.js +57 -0
- package/dist/auth/credentials.js.map +1 -0
- package/dist/auth/destination.d.ts +22 -0
- package/dist/auth/destination.d.ts.map +1 -0
- package/dist/auth/destination.js +49 -0
- package/dist/auth/destination.js.map +1 -0
- package/dist/auth/http.d.ts +12 -0
- package/dist/auth/http.d.ts.map +1 -0
- package/dist/auth/http.js +34 -0
- package/dist/auth/http.js.map +1 -0
- package/dist/auth/login.d.ts +22 -0
- package/dist/auth/login.d.ts.map +1 -0
- package/dist/auth/login.js +98 -0
- package/dist/auth/login.js.map +1 -0
- package/dist/auth/protocol.d.ts +26 -0
- package/dist/auth/protocol.d.ts.map +1 -0
- package/dist/auth/protocol.js +31 -0
- package/dist/auth/protocol.js.map +1 -0
- package/dist/baseline.d.ts +18 -0
- package/dist/baseline.d.ts.map +1 -0
- package/dist/baseline.js +22 -0
- package/dist/baseline.js.map +1 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +7 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli.d.ts +19 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +492 -0
- package/dist/cli.js.map +1 -0
- package/dist/create/choices.d.ts +58 -0
- package/dist/create/choices.d.ts.map +1 -0
- package/dist/create/choices.js +121 -0
- package/dist/create/choices.js.map +1 -0
- package/dist/create/deployment.d.ts +48 -0
- package/dist/create/deployment.d.ts.map +1 -0
- package/dist/create/deployment.js +66 -0
- package/dist/create/deployment.js.map +1 -0
- package/dist/create/scaffold.d.ts +57 -0
- package/dist/create/scaffold.d.ts.map +1 -0
- package/dist/create/scaffold.js +198 -0
- package/dist/create/scaffold.js.map +1 -0
- package/dist/create/source-reference.d.ts +39 -0
- package/dist/create/source-reference.d.ts.map +1 -0
- package/dist/create/source-reference.js +185 -0
- package/dist/create/source-reference.js.map +1 -0
- package/dist/create/template.d.ts +116 -0
- package/dist/create/template.d.ts.map +1 -0
- package/dist/create/template.js +211 -0
- package/dist/create/template.js.map +1 -0
- package/dist/diagnostics.d.ts +6 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +18 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/help.d.ts +16 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +73 -0
- package/dist/help.js.map +1 -0
- package/dist/openapi/bundle.d.ts +18 -0
- package/dist/openapi/bundle.d.ts.map +1 -0
- package/dist/openapi/bundle.js +201 -0
- package/dist/openapi/bundle.js.map +1 -0
- package/dist/openapi/discovery.d.ts +30 -0
- package/dist/openapi/discovery.d.ts.map +1 -0
- package/dist/openapi/discovery.js +325 -0
- package/dist/openapi/discovery.js.map +1 -0
- package/dist/openapi/emit.d.ts +52 -0
- package/dist/openapi/emit.d.ts.map +1 -0
- package/dist/openapi/emit.js +596 -0
- package/dist/openapi/emit.js.map +1 -0
- package/dist/openapi/graphql.d.ts +102 -0
- package/dist/openapi/graphql.d.ts.map +1 -0
- package/dist/openapi/graphql.js +294 -0
- package/dist/openapi/graphql.js.map +1 -0
- package/dist/openapi/identity.d.ts +88 -0
- package/dist/openapi/identity.d.ts.map +1 -0
- package/dist/openapi/identity.js +98 -0
- package/dist/openapi/identity.js.map +1 -0
- package/dist/openapi/mcp.d.ts +21 -0
- package/dist/openapi/mcp.d.ts.map +1 -0
- package/dist/openapi/mcp.js +133 -0
- package/dist/openapi/mcp.js.map +1 -0
- package/dist/openapi/operations.d.ts +165 -0
- package/dist/openapi/operations.d.ts.map +1 -0
- package/dist/openapi/operations.js +361 -0
- package/dist/openapi/operations.js.map +1 -0
- package/dist/openapi/overlay.d.ts +23 -0
- package/dist/openapi/overlay.d.ts.map +1 -0
- package/dist/openapi/overlay.js +115 -0
- package/dist/openapi/overlay.js.map +1 -0
- package/dist/openapi/plugin.d.ts +83 -0
- package/dist/openapi/plugin.d.ts.map +1 -0
- package/dist/openapi/plugin.js +468 -0
- package/dist/openapi/plugin.js.map +1 -0
- package/dist/openapi/polymorphism.d.ts +21 -0
- package/dist/openapi/polymorphism.d.ts.map +1 -0
- package/dist/openapi/polymorphism.js +96 -0
- package/dist/openapi/polymorphism.js.map +1 -0
- package/dist/openapi/postman.d.ts +21 -0
- package/dist/openapi/postman.d.ts.map +1 -0
- package/dist/openapi/postman.js +286 -0
- package/dist/openapi/postman.js.map +1 -0
- package/dist/openapi/schema.d.ts +178 -0
- package/dist/openapi/schema.d.ts.map +1 -0
- package/dist/openapi/schema.js +1234 -0
- package/dist/openapi/schema.js.map +1 -0
- package/dist/openapi/select.d.ts +22 -0
- package/dist/openapi/select.d.ts.map +1 -0
- package/dist/openapi/select.js +79 -0
- package/dist/openapi/select.js.map +1 -0
- package/dist/openapi/spec.d.ts +147 -0
- package/dist/openapi/spec.d.ts.map +1 -0
- package/dist/openapi/spec.js +263 -0
- package/dist/openapi/spec.js.map +1 -0
- package/dist/openapi/swagger.d.ts +166 -0
- package/dist/openapi/swagger.d.ts.map +1 -0
- package/dist/openapi/swagger.js +298 -0
- package/dist/openapi/swagger.js.map +1 -0
- package/dist/openapi/versions.d.ts +52 -0
- package/dist/openapi/versions.d.ts.map +1 -0
- package/dist/openapi/versions.js +120 -0
- package/dist/openapi/versions.js.map +1 -0
- package/dist/plugin/archive.d.ts +27 -0
- package/dist/plugin/archive.d.ts.map +1 -0
- package/dist/plugin/archive.js +170 -0
- package/dist/plugin/archive.js.map +1 -0
- package/dist/plugin/bundle.d.ts +27 -0
- package/dist/plugin/bundle.d.ts.map +1 -0
- package/dist/plugin/bundle.js +328 -0
- package/dist/plugin/bundle.js.map +1 -0
- package/dist/plugin/init.d.ts +18 -0
- package/dist/plugin/init.d.ts.map +1 -0
- package/dist/plugin/init.js +121 -0
- package/dist/plugin/init.js.map +1 -0
- package/dist/plugin/inspection.d.ts +24 -0
- package/dist/plugin/inspection.d.ts.map +1 -0
- package/dist/plugin/inspection.js +24 -0
- package/dist/plugin/inspection.js.map +1 -0
- package/dist/plugin/package.d.ts +26 -0
- package/dist/plugin/package.d.ts.map +1 -0
- package/dist/plugin/package.js +73 -0
- package/dist/plugin/package.js.map +1 -0
- package/dist/plugin/publication.d.ts +29 -0
- package/dist/plugin/publication.d.ts.map +1 -0
- package/dist/plugin/publication.js +65 -0
- package/dist/plugin/publication.js.map +1 -0
- package/dist/plugin/validation.d.ts +15 -0
- package/dist/plugin/validation.d.ts.map +1 -0
- package/dist/plugin/validation.js +119 -0
- package/dist/plugin/validation.js.map +1 -0
- package/dist/release/archives.d.ts +33 -0
- package/dist/release/archives.d.ts.map +1 -0
- package/dist/release/archives.js +81 -0
- package/dist/release/archives.js.map +1 -0
- package/dist/release/release-manifest.d.ts +182 -0
- package/dist/release/release-manifest.d.ts.map +1 -0
- package/dist/release/release-manifest.js +79 -0
- package/dist/release/release-manifest.js.map +1 -0
- package/dist/release/releases.d.ts +36 -0
- package/dist/release/releases.d.ts.map +1 -0
- package/dist/release/releases.js +122 -0
- package/dist/release/releases.js.map +1 -0
- package/dist/skills.d.ts +35 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +257 -0
- package/dist/skills.js.map +1 -0
- package/package.json +73 -4
- package/skills/dual-fde/SKILL.md +38 -0
- package/skills/dual-fde/references/access.md +62 -0
- package/skills/dual-fde/references/author-plugins.md +54 -0
- package/skills/dual-fde/references/cli.md +97 -0
- package/skills/dual-fde/references/manage-plugins.md +78 -0
- package/skills/dual-fde/references/migrations-deployment.md +84 -0
- package/skills/dual-fde/references/openapi-plugins.md +47 -0
- package/skills/dual-fde/references/sdk-docs.md +56 -0
- package/skills/dual-fde/references/upgrades.md +115 -0
- package/skills/dual-fde/references/working-context.md +69 -0
- package/src/auth/credentials.ts +84 -0
- package/src/auth/destination.ts +83 -0
- package/src/auth/http.ts +39 -0
- package/src/auth/login.ts +177 -0
- package/src/auth/protocol.ts +37 -0
- package/src/baseline.ts +15 -0
- package/src/bin.ts +4 -0
- package/src/cli.ts +969 -0
- package/src/create/choices.ts +177 -0
- package/src/create/deployment.ts +96 -0
- package/src/create/scaffold.ts +334 -0
- package/src/create/source-reference.ts +212 -0
- package/src/create/template.ts +300 -0
- package/src/diagnostics.ts +8 -0
- package/src/help.ts +142 -0
- package/src/openapi/bundle.ts +290 -0
- package/src/openapi/discovery.ts +438 -0
- package/src/openapi/emit.ts +1031 -0
- package/src/openapi/graphql.ts +375 -0
- package/src/openapi/identity.ts +153 -0
- package/src/openapi/mcp.ts +165 -0
- package/src/openapi/operations.ts +781 -0
- package/src/openapi/overlay.ts +195 -0
- package/src/openapi/plugin.ts +856 -0
- package/src/openapi/polymorphism.ts +207 -0
- package/src/openapi/postman.ts +403 -0
- package/src/openapi/schema.ts +2138 -0
- package/src/openapi/select.ts +113 -0
- package/src/openapi/spec.ts +401 -0
- package/src/openapi/swagger.ts +422 -0
- package/src/openapi/versions.ts +174 -0
- package/src/plugin/archive.ts +244 -0
- package/src/plugin/bundle.ts +572 -0
- package/src/plugin/init.ts +178 -0
- package/src/plugin/inspection.ts +19 -0
- package/src/plugin/package.ts +140 -0
- package/src/plugin/publication.ts +128 -0
- package/src/plugin/validation.ts +213 -0
- package/src/release/archives.ts +133 -0
- package/src/release/release-manifest.ts +79 -0
- package/src/release/releases.ts +210 -0
- package/src/skills.ts +434 -0
- package/templates/compose/.env.compose.example.hbs +3 -0
- package/templates/compose/.env.host.example.hbs +4 -0
- package/templates/compose/Dockerfile.hbs +12 -0
- package/templates/compose/OPERATIONS.md.hbs +159 -0
- package/templates/compose/_dockerignore +14 -0
- package/templates/compose/compose.external.yaml +7 -0
- package/templates/compose/compose.host-linux.yaml +5 -0
- package/templates/compose/compose.host.yaml.hbs +15 -0
- package/templates/compose/compose.yaml.hbs +85 -0
- package/templates/compose/release.env.hbs +2 -0
- package/templates/default/.env.example.hbs +79 -0
- package/templates/default/README.md.hbs +150 -0
- package/templates/default/_gitignore +11 -0
- package/templates/default/packages/customer-plugin/src/Customer.ts.hbs +17 -0
- package/templates/default/packages/customer-plugin/tsconfig.json +15 -0
- package/templates/default/packages/execution-layer/src/App.ts.hbs +7 -0
- package/templates/default/packages/execution-layer/src/Host.ts.hbs +31 -0
- package/templates/default/packages/execution-layer/src/Telemetry.ts.hbs +23 -0
- package/templates/default/packages/execution-layer/src/api.ts.hbs +21 -0
- package/templates/default/packages/execution-layer/src/bootstrap.ts +22 -0
- package/templates/default/packages/execution-layer/src/migrate.ts +11 -0
- package/templates/default/packages/execution-layer/src/registry-check.ts +29 -0
- package/templates/default/packages/execution-layer/src/registry-sync.ts +14 -0
- package/templates/default/packages/execution-layer/src/worker.ts.hbs +16 -0
- package/templates/default/packages/execution-layer/test/app.host-test.ts.hbs +58 -0
- package/templates/default/packages/execution-layer/test/app.test.ts.hbs +16 -0
- package/templates/default/tsconfig.json +5 -0
- package/templates/default/vitest.config.ts +5 -0
- package/templates/default/vitest.host.config.ts +6 -0
- package/templates/opensandbox/OPEN-SANDBOX.md +25 -0
- package/templates/opensandbox/docker/agent-sandbox.Dockerfile +41 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.js","names":[],"sources":["../../src/plugin/bundle.ts"],"sourcesContent":["import { createRequire, isBuiltin } from \"node:module\";\n\nimport type { PlatformError } from \"effect\";\nimport {\n Array,\n Effect,\n FileSystem,\n MutableHashMap,\n MutableList,\n Order,\n Path,\n Predicate,\n Record,\n Schema,\n} from \"effect\";\n\nimport * as acorn from \"acorn\";\nimport { ChildProcess, ChildProcessSpawner } from \"effect/process\";\n\nimport { ReleaseManifest } from \"#release/release-manifest\";\n\nimport { PluginPackage } from \"./package.ts\";\n\nconst Import = Schema.Struct({ path: Schema.String, external: Schema.optionalKey(Schema.Boolean) });\nconst Metafile = Schema.Struct({\n inputs: Schema.Record(Schema.String, Schema.Struct({ imports: Schema.Array(Import) })),\n outputs: Schema.Record(\n Schema.String,\n Schema.Struct({\n imports: Schema.Array(Import),\n inputs: Schema.Record(Schema.String, Schema.Struct({ bytesInOutput: Schema.Number })),\n entryPoint: Schema.optionalKey(Schema.String),\n }),\n ),\n});\nconst Metadata = Schema.StructWithRest(\n Schema.Struct({\n name: Schema.optionalKey(Schema.String),\n version: ReleaseManifest.ExactVersion,\n license: Schema.optionalKey(Schema.String),\n exports: Schema.optionalKey(Schema.Json),\n }),\n [Schema.Record(Schema.String, Schema.Json)],\n);\n\nfunction targets(value: Schema.Json): string[] {\n if (typeof value === \"string\") return [value];\n if (value === null) return [];\n if (typeof value !== \"object\")\n throw PluginPackage.PackageError.make({ message: \"Unsupported package exports\" });\n return Array.flatMap(Object.values(value), targets);\n}\n\nfunction pattern(expression: acorn.Expression | acorn.SpreadElement): string {\n if (expression.type === \"Literal\" && typeof expression.value === \"string\")\n return expression.value;\n if (\n expression.type === \"BinaryExpression\" &&\n expression.operator === \"+\" &&\n expression.left.type !== \"PrivateIdentifier\"\n )\n return pattern(expression.left) + pattern(expression.right);\n if (expression.type === \"TemplateLiteral\")\n return Array.join(\n Array.map(expression.quasis, part => part.value.cooked ?? part.value.raw),\n \"*\",\n );\n return \"*\";\n}\n\nfunction isNode(value: unknown): value is acorn.AnyNode {\n return (\n Predicate.isObject(value) &&\n Predicate.isString(value[\"type\"]) &&\n Predicate.isNumber(value[\"start\"]) &&\n Predicate.isNumber(value[\"end\"])\n );\n}\n\n// Acorn owns the node shapes; traversing the AST also handles chained import().then() calls.\nfunction references(code: string) {\n const tree = acorn.parse(code, {\n ecmaVersion: \"latest\",\n sourceType: \"module\",\n allowReturnOutsideFunction: true,\n });\n const found = MutableList.make<{\n kind: \"import\" | \"require\" | \"resolve\" | \"asset\";\n path: string;\n }>();\n const visit = (\n expression: acorn.AnyNode,\n parent?: acorn.AnyNode,\n grandparent?: acorn.AnyNode,\n ): void => {\n if (expression.type === \"ImportExpression\")\n MutableList.append(found, { kind: \"import\" as const, path: pattern(expression.source) });\n if (\n expression.type === \"CallExpression\" &&\n expression.callee.type === \"Identifier\" &&\n Array.contains([\"require\", \"__require\"], expression.callee.name) &&\n expression.arguments[0]\n )\n MutableList.append(found, {\n kind: \"require\" as const,\n path: pattern(expression.arguments[0]),\n });\n if (\n expression.type === \"CallExpression\" &&\n expression.callee.type === \"MemberExpression\" &&\n expression.callee.object.type === \"MetaProperty\" &&\n expression.callee.object.meta.name === \"import\" &&\n expression.callee.property.type === \"Identifier\" &&\n Array.contains([\"resolve\", \"require\"], expression.callee.property.name) &&\n expression.arguments[0]\n )\n MutableList.append(found, {\n kind: \"resolve\" as const,\n path: pattern(expression.arguments[0]),\n });\n if (\n expression.type === \"ImportSpecifier\" &&\n expression.imported.type === \"Identifier\" &&\n expression.imported.name === \"createRequire\" &&\n parent?.type === \"ImportDeclaration\" &&\n Array.contains([\"node:module\", \"module\"], parent.source.value)\n )\n MutableList.append(found, { kind: \"resolve\" as const, path: \"createRequire\" });\n if (\n ((expression.type === \"ImportNamespaceSpecifier\" ||\n expression.type === \"ImportDefaultSpecifier\") &&\n parent?.type === \"ImportDeclaration\" &&\n Array.contains([\"node:module\", \"module\"], parent.source.value)) ||\n (expression.type === \"ImportExpression\" &&\n Array.contains([\"node:module\", \"module\"], pattern(expression.source))) ||\n (expression.type === \"CallExpression\" &&\n expression.callee.type === \"Identifier\" &&\n Array.contains([\"require\", \"__require\"], expression.callee.name) &&\n expression.arguments[0] &&\n Array.contains([\"node:module\", \"module\"], pattern(expression.arguments[0])))\n )\n MutableList.append(found, { kind: \"resolve\" as const, path: \"module namespace\" });\n if (expression.type === \"NewExpression\") {\n const base = expression.arguments[1];\n if (\n expression.callee.type === \"Identifier\" &&\n expression.callee.name === \"URL\" &&\n base?.type === \"MemberExpression\" &&\n base.object.type === \"MetaProperty\" &&\n base.object.meta.name === \"import\" &&\n base.object.property.name === \"meta\" &&\n base.property.type === \"Identifier\" &&\n base.property.name === \"url\" &&\n expression.arguments[0]\n ) {\n const receiver = parent?.type === \"MemberExpression\" ? parent : expression;\n const call = receiver === parent ? grandparent : parent;\n const method = call?.type === \"CallExpression\" ? call.callee : undefined;\n const name =\n method?.type === \"Identifier\"\n ? method.name\n : method?.type === \"MemberExpression\" && method.property.type === \"Identifier\"\n ? method.property.name\n : \"\";\n const writing =\n call?.type === \"CallExpression\" &&\n call.arguments[0] === receiver &&\n Array.contains(\n [\n \"writeFile\",\n \"writeFileSync\",\n \"writeFileString\",\n \"appendFile\",\n \"appendFileSync\",\n \"makeDirectory\",\n \"mkdir\",\n \"mkdirSync\",\n ],\n name,\n );\n if (!writing)\n MutableList.append(found, {\n kind: \"asset\" as const,\n path: pattern(expression.arguments[0]),\n });\n }\n }\n const fields: unknown[] = Object.values(expression);\n for (const field of fields) {\n if (isNode(field)) visit(field, expression, parent);\n else if (Array.isArray(field))\n for (const child of field) if (isNode(child)) visit(child, expression, parent);\n }\n };\n visit(tree);\n return MutableList.toArray(found);\n}\n\nexport const make = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;\n return Effect.fn(\"PluginBundle.build\")(function* (\n root: string,\n prepared: PluginPackage.Prepared,\n ) {\n const json = Effect.fnUntraced(function* (file: string) {\n return yield* Schema.decodeEffect(Schema.fromJsonString(Metadata))(\n yield* fs.readFileString(file),\n );\n });\n const manifest = yield* json(path.join(root, \"package.json\"));\n const require = createRequire(prepared.entrypoint);\n const sdkRoot = path.dirname(require.resolve(\"@dual-os/sdk/package.json\"));\n const sdk = yield* json(path.join(sdkRoot, \"package.json\"));\n const sdkRunner = yield* fs.realPath(require.resolve(\"@dual-os/sdk/Runner\"));\n const input = path.join(root, \".dual/bundle-input\");\n const output = path.join(root, \".dual/bundle-output\");\n for (const directory of [input, output]) {\n if (yield* fs.exists(directory)) yield* fs.remove(directory, { recursive: true });\n yield* fs.makeDirectory(directory, { recursive: true });\n }\n const safe = Effect.fnUntraced(function* (name: string) {\n const relative = path.relative(root, path.resolve(root, name));\n if (\n relative === \"\" ||\n relative.startsWith(\"..\") ||\n path.isAbsolute(relative) ||\n Array.some(\n relative.split(path.sep),\n part =>\n [\"node_modules\", \".dual\", \".env\", \".npmrc\", \".netrc\"].includes(part) ||\n part.startsWith(\".env.\"),\n )\n )\n return yield* PluginPackage.PackageError.make({ message: `Unsafe bundle path: ${name}` });\n const source = path.resolve(root, name);\n const real = yield* fs.realPath(source);\n if (!real.startsWith(`${root}${path.sep}`))\n return yield* PluginPackage.PackageError.make({\n message: `Bundle file escapes the package: ${name}`,\n });\n return { source, relative };\n });\n const copy = Effect.fnUntraced(function* (name: string, destination: string) {\n const file = yield* safe(name);\n if ((yield* fs.stat(file.source)).type !== \"File\")\n return yield* PluginPackage.PackageError.make({\n message: `Bundle export must be a file: ${name}`,\n });\n const bytes = yield* fs.readFile(file.source);\n if (/\\.[cm]?tsx?$/u.test(name) && !/\\.d\\.[cm]?ts$/u.test(name))\n return yield* PluginPackage.PackageError.make({\n message: `Source exports/assets cannot be shipped in a JavaScript bundle: ${name}`,\n });\n const prefix = Buffer.from(bytes.subarray(0, 4));\n if (\n /\\.(?:node|dll|dylib|exe|so(?:\\.[0-9.]+)?)$|(?:^|\\/)binding\\.gyp$/iu.test(name) ||\n (prefix.length === 4 &&\n [\n 0x7f454c46, 0xfeedface, 0xcefaedfe, 0xfeedfacf, 0xcffaedfe, 0xcafebabe, 0xbebafeca,\n ].includes(prefix.readUInt32BE(0))) ||\n (prefix.length >= 2 && prefix.readUInt16BE(0) === 0x4d5a)\n )\n return yield* PluginPackage.PackageError.make({\n message: `Native bundle content is unsupported: ${name}`,\n });\n yield* fs.makeDirectory(path.dirname(path.join(destination, file.relative)), {\n recursive: true,\n });\n yield* fs.copyFile(file.source, path.join(destination, file.relative));\n });\n const publicFiles = MutableList.make<string>();\n for (const target of yield* Effect.try(() => targets(manifest.exports ?? {}))) {\n const matches = yield* fs.glob(target, { root });\n if (Array.isArrayEmpty(matches))\n return yield* PluginPackage.PackageError.make({\n message: `Missing public export: ${target}`,\n });\n MutableList.appendAll(publicFiles, matches);\n }\n const declared = Array.dedupe([\n ...MutableList.toArray(publicFiles),\n path.relative(root, prepared.entrypoint),\n ...Array.map(prepared.assets, file => path.relative(root, file)),\n ]);\n // Static helpers can live above any public entrypoint; only the bundler's reachable graph ships.\n const declarations = MutableList.make<string>();\n for (const file of yield* fs.glob(\"**/*\", {\n root,\n exclude: [\"node_modules/**\", \".dual/**\", \".git/**\"],\n })) {\n const source = path.join(root, file);\n if ((yield* fs.stat(source)).type !== \"File\") continue;\n if (/\\.d\\.[cm]?ts(?:\\.map)?$/u.test(file)) {\n yield* copy(file, output);\n MutableList.append(declarations, file);\n }\n if (\n /\\.(?:[cm]?js|json|map)$/.test(file) &&\n !Array.some(file.split(\"/\"), part => part.startsWith(\".\"))\n )\n yield* copy(path.relative(root, source), input);\n }\n for (const file of declared) {\n yield* copy(file, input);\n if (!/\\.(?:[cm]?js)$/.test(file)) yield* copy(file, output);\n }\n for (const file of [\"README.md\", \"LICENSE\", \"LICENSE.md\", \"LICENSE.txt\"]) {\n if (yield* fs.exists(path.join(root, file))) yield* copy(file, output);\n }\n yield* fs.writeFileString(\n path.join(input, \"package.json\"),\n yield* fs.readFileString(path.join(root, \"package.json\")),\n );\n // Resolve the same installed graph as the source package, including workspace hoisting.\n const modules = Effect.fnUntraced(function* (\n directory: string,\n ): Effect.fn.Return<string, PlatformError.PlatformError | PluginPackage.PackageError> {\n if (yield* fs.exists(path.join(directory, \"node_modules\")))\n return path.join(directory, \"node_modules\");\n const parent = path.dirname(directory);\n if (parent === directory)\n return yield* PluginPackage.PackageError.make({\n message: \"Install build dependencies from a frozen lockfile first\",\n });\n return yield* modules(parent);\n });\n yield* fs.symlink(yield* modules(root), path.join(input, \"node_modules\"));\n const runnerName = Effect.fnUntraced(function* (\n index: number,\n ): Effect.fn.Return<string, PlatformError.PlatformError> {\n const name = index === 0 ? \"Runner.js\" : `Runner-${index}.js`;\n return (yield* fs.exists(path.join(input, name))) ? yield* runnerName(index + 1) : name;\n });\n const runner = yield* runnerName(0);\n yield* fs.writeFileString(path.join(input, runner), 'import \"@dual-os/sdk/Runner\";\\n');\n const entries = Array.dedupe([\n ...Array.filter(declared, file => /\\.(?:[cm]?js)$/.test(file)),\n runner,\n ]);\n const metaPath = path.join(root, \".dual/bundle-metafile.json\");\n const code = yield* spawner.exitCode(\n ChildProcess.make(\n \"bun\",\n [\n \"build\",\n \"--no-env-file\",\n \"--target=bun\",\n \"--format=esm\",\n \"--splitting\",\n \"--keep-names\",\n \"--sourcemap=linked\",\n `--metafile=${metaPath}`,\n \"--root\",\n input,\n \"--outdir\",\n output,\n ...Array.map(entries, file => path.resolve(input, file)),\n ],\n { cwd: input, stdin: \"ignore\", stdout: \"ignore\", stderr: \"inherit\" },\n ),\n );\n if (code !== 0)\n return yield* PluginPackage.PackageError.make({\n message: \"Self-contained plugin compilation failed; no installation fallback is available\",\n });\n const meta = yield* Schema.decodeEffect(Schema.fromJsonString(Metafile))(\n yield* fs.readFileString(metaPath),\n );\n const emitted = Record.fromEntries(\n Array.flatMap(Object.entries(meta.outputs), entry =>\n entry[1].entryPoint\n ? [\n [\n path.relative(input, path.resolve(input, entry[1].entryPoint)),\n entry[0].replace(/^\\.\\//u, \"\"),\n ] as const,\n ]\n : [],\n ),\n );\n const rewrite = (value: Schema.Json): Schema.Json => {\n if (typeof value === \"string\")\n return emitted[path.normalize(value)]\n ? `./${emitted[path.normalize(value)]}`\n : value.replace(/\\.[cm]js$/u, \".js\");\n if (value === null || typeof value !== \"object\") return value;\n if (Array.isArray<Schema.Json>(value)) return Array.map(value, rewrite);\n return Record.map(value, rewrite);\n };\n const packages = MutableHashMap.empty<\n string,\n { name: string; version: string; license: string; licenses: string[] }\n >();\n const contributing = Array.dedupe(\n Array.flatMap(Object.values(meta.outputs), result =>\n Array.map(\n Array.filter(Object.entries(result.inputs), entry => entry[1].bytesInOutput > 0),\n entry => entry[0],\n ),\n ),\n );\n for (const file of contributing) {\n const source = yield* fs.realPath(path.resolve(input, file));\n const body = yield* fs.readFileString(source);\n for (const reference of /\\.[cm]?js$/.test(source)\n ? yield* Effect.try(() => references(body))\n : []) {\n if (\n reference.kind === \"resolve\" &&\n Array.contains([\"createRequire\", \"module namespace\"], reference.path)\n )\n continue;\n if (reference.kind === \"import\" && source === sdkRunner) continue;\n if (isBuiltin(reference.path) || reference.path.startsWith(\"bun:\")) continue;\n if (reference.kind === \"asset\" && /^(?!file:)[a-z][a-z\\d+.-]*:/iu.test(reference.path))\n continue;\n if (reference.kind === \"resolve\")\n return yield* PluginPackage.PackageError.make({\n message: `Runtime package resolution cannot be bundled in ${file}: ${reference.path}; use an import instead`,\n });\n if (reference.kind !== \"asset\" && !reference.path.includes(\"*\")) continue;\n if (reference.kind === \"require\")\n return yield* PluginPackage.PackageError.make({\n message: `Unresolved computed require in ${file}; use finite imports and declare dual.plugin.assets`,\n });\n if (!reference.path.startsWith(\".\"))\n return yield* PluginPackage.PackageError.make({\n message: `Unresolved dynamic import/resource in ${file}: ${reference.path}. Declare finite relative files in dual.plugin.assets.`,\n });\n const matches = yield* fs.glob(reference.path, { root: path.dirname(source) });\n if (Array.isArrayEmpty(matches))\n return yield* PluginPackage.PackageError.make({\n message: `Missing dynamic import/resource in ${file}: ${reference.path}`,\n });\n if (reference.path.includes(\"*\"))\n for (const match of matches) {\n const relative = path.relative(input, path.resolve(path.dirname(source), match));\n if (!Array.some(declared, name => path.normalize(name) === relative))\n return yield* PluginPackage.PackageError.make({\n message: `Declare dynamic file in dual.plugin.assets: ${relative}`,\n });\n }\n }\n if (source.startsWith(`${input}${path.sep}`)) continue;\n const owner = Effect.fnUntraced(function* (\n directory: string,\n ): Effect.fn.Return<string, PlatformError.PlatformError | PluginPackage.PackageError> {\n if (yield* fs.exists(path.join(directory, \"package.json\"))) return directory;\n const parent = path.dirname(directory);\n if (parent === directory)\n return yield* PluginPackage.PackageError.make({\n message: `Dependency has no package manifest: ${source}`,\n });\n return yield* owner(parent);\n });\n const directory = yield* owner(path.dirname(source));\n if (MutableHashMap.has(packages, directory)) continue;\n const pkg = yield* json(path.join(directory, \"package.json\"));\n if (!pkg.name || !pkg.license)\n return yield* PluginPackage.PackageError.make({\n message: `Dependency lacks name/license metadata: ${directory}`,\n });\n const licenseFiles = (yield* fs.glob(\"{LICENSE,LICENCE,COPYING,NOTICE}{,.md,.txt}\", {\n root: directory,\n })).sort();\n if (Array.isArrayEmpty(licenseFiles))\n return yield* PluginPackage.PackageError.make({\n message: `Dependency attribution missing: ${pkg.name}@${pkg.version}`,\n });\n const licenses = MutableList.make<string>();\n for (const license of licenseFiles) {\n if ((yield* fs.stat(path.join(directory, license))).size === 0n)\n return yield* PluginPackage.PackageError.make({\n message: `Empty dependency attribution: ${pkg.name}@${pkg.version}: ${license}`,\n });\n const target = `licenses/${pkg.name.replaceAll(\"/\", \"_\")}@${pkg.version}/${license}`;\n yield* fs.makeDirectory(path.dirname(path.join(output, target)), { recursive: true });\n yield* fs.copyFile(path.join(directory, license), path.join(output, target));\n MutableList.append(licenses, target);\n }\n MutableHashMap.set(packages, directory, {\n name: pkg.name,\n version: pkg.version,\n license: pkg.license,\n licenses: MutableList.toArray(licenses),\n });\n }\n for (const [file, metadata] of Object.entries(meta.outputs)) {\n for (const imported of metadata.imports) {\n if (isBuiltin(imported.path) || imported.path.startsWith(\"bun:\")) continue;\n if (\n imported.external ||\n !imported.path.startsWith(\".\") ||\n !(yield* fs.exists(path.resolve(output, imported.path)))\n )\n return yield* PluginPackage.PackageError.make({\n message: `Unbundled dependency in ${file}: ${imported.path}`,\n });\n }\n if (!/\\.[cm]?js$/.test(file)) continue;\n const outputCode = yield* fs.readFileString(path.resolve(output, file));\n for (const reference of yield* Effect.try(() => references(outputCode))) {\n if (\n reference.kind === \"resolve\" &&\n Array.contains([\"createRequire\", \"module namespace\"], reference.path)\n )\n return yield* PluginPackage.PackageError.make({\n message: `Runtime package resolution cannot be bundled in ${file}: ${reference.path}; use static named imports instead`,\n });\n if (\n reference.kind === \"require\" &&\n !isBuiltin(reference.path) &&\n !reference.path.startsWith(\"bun:\")\n )\n return yield* PluginPackage.PackageError.make({\n message: `Unbundled require in ${file}: ${reference.path}; no installation fallback is available`,\n });\n if (\n reference.kind === \"import\" &&\n reference.path.startsWith(\".\") &&\n reference.path.includes(\"*\") &&\n Array.isArrayEmpty(\n yield* fs.glob(reference.path, { root: path.resolve(output, path.dirname(file)) }),\n )\n )\n return yield* PluginPackage.PackageError.make({\n message: `Bundle dynamic import is missing after splitting: ${file}: ${reference.path}`,\n });\n if (reference.kind !== \"asset\") continue;\n if (/^(?!file:)[a-z][a-z\\d+.-]*:/iu.test(reference.path)) continue;\n if (!(yield* fs.exists(path.resolve(output, path.dirname(file), reference.path))))\n return yield* PluginPackage.PackageError.make({\n message: `Bundle resource is missing after splitting: ${file}: ${reference.path}`,\n });\n }\n }\n return {\n output,\n sdkVersion: sdk.version,\n runner: emitted[runner] ?? runner,\n manifest: { ...manifest, exports: rewrite(manifest.exports ?? {}) },\n entrypoint:\n emitted[path.relative(root, prepared.entrypoint)] ??\n path.relative(root, prepared.entrypoint),\n assets: Array.dedupe([\n ...Array.map(prepared.assets, file => {\n const relative = path.relative(root, file);\n return emitted[relative] ?? relative;\n }),\n ...MutableList.toArray(declarations),\n ...Array.filter(MutableList.toArray(publicFiles), file => !/\\.[cm]?js$/u.test(file)),\n ...Array.map(\n Array.filter(Object.keys(meta.outputs), file => !/\\.[cm]?js$/u.test(file)),\n file => file.replace(/^\\.\\//u, \"\"),\n ),\n ]),\n publicJavaScript: Array.map(\n Array.filter(MutableList.toArray(publicFiles), file => /\\.[cm]?js$/u.test(file)),\n source => ({ source, output: emitted[path.normalize(source)] ?? source }),\n ),\n packages: Array.sort(\n Array.fromIterable(MutableHashMap.values(packages)),\n Order.mapInput(\n Order.String,\n (pkg: { name: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G,YAAY,QAAQ,YAAY;IACnC,GAAG,MAAM,OAAO,YAAY,QAAQ,WAAW,IAAG,SAAQ,CAAC,cAAc,KAAK,IAAI,CAAC;IACnF,GAAG,MAAM,IACP,MAAM,OAAO,OAAO,KAAK,KAAK,OAAO,IAAG,SAAQ,CAAC,cAAc,KAAK,IAAI,CAAC,IACzE,SAAQ,KAAK,QAAQ,UAAU,EAAE,CACnC;GACF,CAAC;GACD,kBAAkB,MAAM,IACtB,MAAM,OAAO,YAAY,QAAQ,WAAW,IAAG,SAAQ,cAAc,KAAK,IAAI,CAAC,IAC/E,YAAW;IAAE;IAAQ,QAAQ,QAAQ,KAAK,UAAU,MAAM,MAAM;GAAO,EACzE;GACA,UAAU,MAAM,KACd,MAAM,aAAa,eAAe,OAAO,QAAQ,CAAC,GAClD,MAAM,SACJ,MAAM,SACL,QAA2C,GAAG,IAAI,KAAK,GAAG,IAAI,SACjE,CACF;EACF;CACF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "./init.js";
|
|
2
|
+
import { Context, Effect, FileSystem, Layer, Path, Schema } from "effect";
|
|
3
|
+
declare namespace init_d_exports {
|
|
4
|
+
export { InitError, Interface, init_d_exports as PluginInit, Service, layer };
|
|
5
|
+
}
|
|
6
|
+
declare const InitError_base: Schema.Class<InitError, Schema.TaggedStruct<"InitError", {
|
|
7
|
+
readonly cause: Schema.optionalKey<Schema.Redacted<Schema.Defect>>;
|
|
8
|
+
readonly message: Schema.String;
|
|
9
|
+
}>, import("effect/Cause").YieldableError>;
|
|
10
|
+
export declare class InitError extends InitError_base {}
|
|
11
|
+
export type Interface = {
|
|
12
|
+
readonly create: (directory: string) => Effect.Effect<string, InitError>;
|
|
13
|
+
};
|
|
14
|
+
declare const Service_base: Context.ServiceClass<Service, "@dual-os/cli/plugin/init/Service", Interface>;
|
|
15
|
+
export declare class Service extends Service_base {}
|
|
16
|
+
export declare const layer: Layer.Layer<Service, never, FileSystem.FileSystem | Path.Path>;
|
|
17
|
+
export { init_d_exports as PluginInit };
|
|
18
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","names":[],"sources":["../../src/plugin/init.ts"],"mappings":";;;;;;;;;qBAgCa,kBAAkB;YAKnB;WACD,SAAS,sBAAsB,OAAO,eAAe;;;qBAEnD,gBAAgB;qBAIhB,OAAK,MAAA,MAAA,gBAAA,WAAA,aAAA,KAAA"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { versions } from "../baseline.js";
|
|
3
|
+
import "./init.js";
|
|
4
|
+
import { createRequire } from "node:module";
|
|
5
|
+
import { Array, Context, Effect, FileSystem, Layer, Path, Record, Redacted, Schema, String, pipe } from "effect";
|
|
6
|
+
import { Diagnostics } from "#diagnostics";
|
|
7
|
+
import { lstat } from "node:fs/promises";
|
|
8
|
+
// src/plugin/init.ts
|
|
9
|
+
var init_exports = /* @__PURE__ */ __exportAll({
|
|
10
|
+
InitError: () => InitError,
|
|
11
|
+
PluginInit: () => init_exports,
|
|
12
|
+
Service: () => Service,
|
|
13
|
+
layer: () => layer
|
|
14
|
+
});
|
|
15
|
+
const Identifier = Schema.String.check(Schema.isPattern(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u));
|
|
16
|
+
const SdkManifest = Schema.Struct({
|
|
17
|
+
dependencies: Schema.Struct({ effect: Schema.NonEmptyString }),
|
|
18
|
+
version: Schema.NonEmptyString
|
|
19
|
+
});
|
|
20
|
+
const MissingFile = Schema.Struct({ code: Schema.Literal("ENOENT") });
|
|
21
|
+
var InitError = class extends Schema.TaggedError()("InitError", {
|
|
22
|
+
cause: Schema.optionalKey(Schema.Redacted(Schema.Defect())),
|
|
23
|
+
message: Schema.String
|
|
24
|
+
}) {};
|
|
25
|
+
var Service = class extends Context.Service()("@dual-os/cli/plugin/init/Service") {};
|
|
26
|
+
const layer = Layer.effect(Service, Effect.gen(function* () {
|
|
27
|
+
const fs = yield* FileSystem.FileSystem;
|
|
28
|
+
const path = yield* Path.Path;
|
|
29
|
+
const emptyDestination = Effect.fnUntraced(function* (destination) {
|
|
30
|
+
const info = yield* pipe(Effect.tryPromise(() => lstat(destination)), Effect.catchIf((error) => Schema.is(MissingFile)(error.cause), () => Effect.void), Effect.uninterruptible);
|
|
31
|
+
if (info === void 0) return;
|
|
32
|
+
if (!info.isDirectory() || info.isSymbolicLink() || Array.isReadonlyArrayNonEmpty(yield* fs.readDirectory(destination))) return yield* InitError.make({ message: "Choose an absent or empty directory, not a file or symlink. No files were overwritten." });
|
|
33
|
+
});
|
|
34
|
+
return Service.of({ create: Effect.fn("PluginInit.create")(function* (directory) {
|
|
35
|
+
const destination = path.resolve(directory);
|
|
36
|
+
const identifier = yield* pipe(Schema.decodeEffect(Identifier)(path.basename(destination)), Effect.mapError((cause) => InitError.make({
|
|
37
|
+
cause: Redacted.make(cause),
|
|
38
|
+
message: "Use a directory name in lowercase kebab-case, starting with a letter, such as my-plugin."
|
|
39
|
+
})));
|
|
40
|
+
yield* emptyDestination(destination);
|
|
41
|
+
const sdk = yield* Schema.decodeEffect(Schema.fromJsonString(SdkManifest))(yield* fs.readFileString(createRequire(import.meta.url).resolve("@dual-os/sdk/package.json")));
|
|
42
|
+
const quotedIdentifier = yield* Schema.encodeEffect(Schema.fromJsonString(Schema.String))(identifier);
|
|
43
|
+
const files = {
|
|
44
|
+
".gitignore": "node_modules/\ndist/\n.dual/\n.env\n.env.*\n",
|
|
45
|
+
"README.md": `# ${identifier}\n\nThis standalone plugin uses the Dual SDK and exposes a ping action.\n\nUse Bun 1.4.2 and public npm, then run:\n\n\`\`\`sh\nbun install\n# Commit bun.lock before building a release.\nbun run build\ndual plugin validate\ndual plugin build\n\`\`\`\n\nThe self-contained archive is .dual/plugin.tgz. It includes the SDK, Effect, runner, JavaScript dependencies and licenses; the sandbox never installs packages. Build and validation do not publish or activate the plugin.\nDeclare finite dynamic-import helpers, child scripts and resources in dual.plugin.assets.\nEdit src/plugin.ts to add actions and handlers. The release version comes only from package.json. Publish a new package version for every code or contract change.\n\nTo upload, authorize with dual login --web --url <deployment-url>, then run dual plugin push.\nThe deployment must support plugin uploads.\n`,
|
|
46
|
+
"package.json": yield* Schema.encodeEffect(Schema.fromJsonString(Schema.JsonObject, { space: 2 }))({
|
|
47
|
+
dependencies: {
|
|
48
|
+
"@dual-os/sdk": sdk.version,
|
|
49
|
+
effect: sdk.dependencies.effect
|
|
50
|
+
},
|
|
51
|
+
devDependencies: { typescript: versions.typescript },
|
|
52
|
+
dual: { plugin: {
|
|
53
|
+
entrypoint: "dist/plugin.js",
|
|
54
|
+
export: "default"
|
|
55
|
+
} },
|
|
56
|
+
exports: "./dist/plugin.js",
|
|
57
|
+
files: ["dist"],
|
|
58
|
+
name: identifier,
|
|
59
|
+
private: true,
|
|
60
|
+
scripts: { build: "tsc -p tsconfig.json" },
|
|
61
|
+
type: "module",
|
|
62
|
+
version: "1.0.0"
|
|
63
|
+
}),
|
|
64
|
+
"src/plugin.ts": `import { Action, Plugin } from "@dual-os/sdk";
|
|
65
|
+
import { Effect, Schema, pipe } from "effect";
|
|
66
|
+
|
|
67
|
+
const ping = pipe(
|
|
68
|
+
Action.make("ping", { description: "Echo a message to verify the plugin.",
|
|
69
|
+
input: Schema.Struct({ message: Schema.String }),
|
|
70
|
+
output: Schema.Struct({ echoed: Schema.String }),
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const plugin = Plugin.make(${quotedIdentifier}).pipe(Plugin.withAction(ping));
|
|
75
|
+
const handlers = Plugin.toLayer(plugin, handlers => handlers.action("ping", input => Effect.succeed({ echoed: input.message })));
|
|
76
|
+
|
|
77
|
+
export default pipe(
|
|
78
|
+
plugin,
|
|
79
|
+
Plugin.provide(handlers),
|
|
80
|
+
);
|
|
81
|
+
`,
|
|
82
|
+
"tsconfig.json": yield* Schema.encodeEffect(Schema.fromJsonString(Schema.JsonObject, { space: 2 }))({
|
|
83
|
+
compilerOptions: {
|
|
84
|
+
declaration: true,
|
|
85
|
+
module: "NodeNext",
|
|
86
|
+
moduleResolution: "NodeNext",
|
|
87
|
+
noEmitOnError: true,
|
|
88
|
+
outDir: "dist",
|
|
89
|
+
rootDir: "src",
|
|
90
|
+
skipLibCheck: true,
|
|
91
|
+
strict: true,
|
|
92
|
+
target: "ES2022"
|
|
93
|
+
},
|
|
94
|
+
include: ["src/**/*.ts"]
|
|
95
|
+
})
|
|
96
|
+
};
|
|
97
|
+
yield* fs.makeDirectory(path.dirname(destination), { recursive: true });
|
|
98
|
+
const temporary = yield* fs.makeTempDirectoryScoped({
|
|
99
|
+
directory: path.dirname(destination),
|
|
100
|
+
prefix: ".dual-plugin-init-"
|
|
101
|
+
});
|
|
102
|
+
const staging = path.join(temporary, "plugin");
|
|
103
|
+
yield* fs.makeDirectory(staging);
|
|
104
|
+
yield* pipe(Effect.gen(function* () {
|
|
105
|
+
for (const file of Record.toEntries(files)) {
|
|
106
|
+
const target = path.join(staging, file[0]);
|
|
107
|
+
yield* fs.makeDirectory(path.dirname(target), { recursive: true });
|
|
108
|
+
yield* fs.writeFileString(target, `${String.trimEnd(file[1])}\n`, { flag: "wx" });
|
|
109
|
+
}
|
|
110
|
+
yield* emptyDestination(destination);
|
|
111
|
+
yield* fs.rename(staging, destination);
|
|
112
|
+
}), Effect.uninterruptible);
|
|
113
|
+
return destination;
|
|
114
|
+
}, Effect.scoped, Effect.mapError((cause) => Schema.is(InitError)(cause) ? cause : InitError.make({
|
|
115
|
+
cause: Redacted.make(cause),
|
|
116
|
+
message: Diagnostics.format(cause)
|
|
117
|
+
}))) });
|
|
118
|
+
}));
|
|
119
|
+
export { InitError, init_exports as PluginInit, Service, layer };
|
|
120
|
+
|
|
121
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","names":[],"sources":["../../src/plugin/init.ts"],"sourcesContent":["// @effect-diagnostics-next-line nodeBuiltinImport:off -- Effect FileSystem.stat follows links; destination checks require lstat.\nimport { lstat } from \"node:fs/promises\";\nimport { createRequire } from \"node:module\";\n\nimport {\n Array,\n Context,\n Effect,\n FileSystem,\n Layer,\n Path,\n Record,\n Redacted,\n Schema,\n String,\n pipe,\n} from \"effect\";\n\nimport { Diagnostics } from \"#diagnostics\";\n\nimport { Baseline } from \"../baseline.ts\";\n\ntype Identifier = typeof Identifier.Type;\nconst Identifier = Schema.String.check(Schema.isPattern(/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u));\ntype SdkManifest = typeof SdkManifest.Type;\nconst SdkManifest = Schema.Struct({\n dependencies: Schema.Struct({ effect: Schema.NonEmptyString }),\n version: Schema.NonEmptyString,\n});\ntype MissingFile = typeof MissingFile.Type;\nconst MissingFile = Schema.Struct({ code: Schema.Literal(\"ENOENT\") });\n\nexport class InitError extends Schema.TaggedError<InitError>()(\"InitError\", {\n cause: Schema.optionalKey(Schema.Redacted(Schema.Defect())),\n message: Schema.String,\n}) {}\n\nexport type Interface = {\n readonly create: (directory: string) => Effect.Effect<string, InitError>;\n};\nexport class Service extends Context.Service<Service, Interface>()(\n \"@dual-os/cli/plugin/init/Service\",\n) {}\n\nexport const layer = Layer.effect(\n Service,\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const emptyDestination = Effect.fnUntraced(function* (destination: string) {\n const info = yield* pipe(\n Effect.tryPromise(() => lstat(destination)),\n Effect.catchIf(\n error => Schema.is(MissingFile)(error.cause),\n () => Effect.void,\n ),\n Effect.uninterruptible,\n );\n if (info === undefined) return;\n if (\n !info.isDirectory() ||\n info.isSymbolicLink() ||\n Array.isReadonlyArrayNonEmpty(yield* fs.readDirectory(destination))\n ) {\n return yield* InitError.make({\n message:\n \"Choose an absent or empty directory, not a file or symlink. No files were overwritten.\",\n });\n }\n });\n return Service.of({\n create: Effect.fn(\"PluginInit.create\")(\n function* (directory: string) {\n const destination = path.resolve(directory);\n const identifier = yield* pipe(\n Schema.decodeEffect(Identifier)(path.basename(destination)),\n Effect.mapError(cause =>\n InitError.make({\n cause: Redacted.make(cause),\n message:\n \"Use a directory name in lowercase kebab-case, starting with a letter, such as my-plugin.\",\n }),\n ),\n );\n yield* emptyDestination(destination);\n const sdk = yield* Schema.decodeEffect(Schema.fromJsonString(SdkManifest))(\n yield* fs.readFileString(\n createRequire(import.meta.url).resolve(\"@dual-os/sdk/package.json\"),\n ),\n );\n const quotedIdentifier = yield* Schema.encodeEffect(Schema.fromJsonString(Schema.String))(\n identifier,\n );\n const files = {\n \".gitignore\": \"node_modules/\\ndist/\\n.dual/\\n.env\\n.env.*\\n\",\n \"README.md\": `# ${identifier}\\n\\nThis standalone plugin uses the Dual SDK and exposes a ping action.\\n\\nUse Bun 1.4.2 and public npm, then run:\\n\\n\\`\\`\\`sh\\nbun install\\n# Commit bun.lock before building a release.\\nbun run build\\ndual plugin validate\\ndual plugin build\\n\\`\\`\\`\\n\\nThe self-contained archive is .dual/plugin.tgz. It includes the SDK, Effect, runner, JavaScript dependencies and licenses; the sandbox never installs packages. Build and validation do not publish or activate the plugin.\\nDeclare finite dynamic-import helpers, child scripts and resources in dual.plugin.assets.\\nEdit src/plugin.ts to add actions and handlers. The release version comes only from package.json. Publish a new package version for every code or contract change.\\n\\nTo upload, authorize with dual login --web --url <deployment-url>, then run dual plugin push.\\nThe deployment must support plugin uploads.\\n`,\n \"package.json\": yield* Schema.encodeEffect(\n Schema.fromJsonString(Schema.JsonObject, { space: 2 }),\n )({\n dependencies: { \"@dual-os/sdk\": sdk.version, effect: sdk.dependencies.effect },\n devDependencies: { typescript: Baseline.versions.typescript },\n dual: { plugin: { entrypoint: \"dist/plugin.js\", export: \"default\" } },\n exports: \"./dist/plugin.js\",\n files: [\"dist\"],\n name: identifier,\n private: true,\n scripts: { build: \"tsc -p tsconfig.json\" },\n type: \"module\",\n version: \"1.0.0\",\n }),\n \"src/plugin.ts\": `import { Action, Plugin } from \"@dual-os/sdk\";\nimport { Effect, Schema, pipe } from \"effect\";\n\nconst ping = pipe(\n Action.make(\"ping\", { description: \"Echo a message to verify the plugin.\",\n input: Schema.Struct({ message: Schema.String }),\n output: Schema.Struct({ echoed: Schema.String }),\n }),\n);\n\nconst plugin = Plugin.make(${quotedIdentifier}).pipe(Plugin.withAction(ping));\nconst handlers = Plugin.toLayer(plugin, handlers => handlers.action(\"ping\", input => Effect.succeed({ echoed: input.message })));\n\nexport default pipe(\n plugin,\n Plugin.provide(handlers),\n);\n`,\n \"tsconfig.json\": yield* Schema.encodeEffect(\n Schema.fromJsonString(Schema.JsonObject, { space: 2 }),\n )({\n compilerOptions: {\n declaration: true,\n module: \"NodeNext\",\n moduleResolution: \"NodeNext\",\n noEmitOnError: true,\n outDir: \"dist\",\n rootDir: \"src\",\n skipLibCheck: true,\n strict: true,\n target: \"ES2022\",\n },\n include: [\"src/**/*.ts\"],\n }),\n };\n yield* fs.makeDirectory(path.dirname(destination), { recursive: true });\n const temporary = yield* fs.makeTempDirectoryScoped({\n directory: path.dirname(destination),\n prefix: \".dual-plugin-init-\",\n });\n const staging = path.join(temporary, \"plugin\");\n yield* fs.makeDirectory(staging);\n yield* pipe(\n Effect.gen(function* () {\n for (const file of Record.toEntries(files)) {\n const target = path.join(staging, file[0]);\n yield* fs.makeDirectory(path.dirname(target), { recursive: true });\n yield* fs.writeFileString(target, `${String.trimEnd(file[1])}\\n`, { flag: \"wx\" });\n }\n yield* emptyDestination(destination);\n yield* fs.rename(staging, destination);\n }),\n Effect.uninterruptible,\n );\n return destination;\n },\n Effect.scoped,\n Effect.mapError(cause =>\n Schema.is(InitError)(cause)\n ? cause\n : InitError.make({ cause: Redacted.make(cause), message: Diagnostics.format(cause) }),\n ),\n ),\n });\n }),\n);\n\nexport * as PluginInit from \"./init.ts\";\n"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAM,aAAa,OAAO,OAAO,MAAM,OAAO,UAA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UAAU,KAAK,KAAK,WAAW,QAAQ;EAC7C,OAAO,GAAG,cAAc,OAAO;EAC/B,OAAO,KACL,OAAO,IAAI,aAAa;GACtB,KAAK,MAAM,QAAQ,OAAO,UAAU,KAAK,GAAG;IAC1C,MAAM,SAAS,KAAK,KAAK,SAAS,KAAK,EAAE;IACzC,OAAO,GAAG,cAAc,KAAK,QAAQ,MAAM,GAAG,EAAE,WAAW,KAAK,CAAC;IACjE,OAAO,GAAG,gBAAgB,QAAQ,GAAG,OAAO,QAAQ,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;GAClF;GACA,OAAO,iBAAiB,WAAW;GACnC,OAAO,GAAG,OAAO,SAAS,WAAW;EACvC,CAAC,GACD,OAAO,eACT;EACA,OAAO;CACT,GACA,OAAO,QACP,OAAO,UAAS,UACd,OAAO,GAAG,SAAS,CAAC,CAAC,KAAK,IACtB,QACA,UAAU,KAAK;EAAE,OAAO,SAAS,KAAK,KAAK;EAAG,SAAS,YAAY,OAAO,KAAK;CAAE,CAAC,CACxF,CACF,EACF,CAAC;AACH,CAAC,CACH"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "./inspection.js";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
declare namespace inspection_d_exports {
|
|
4
|
+
export { Output, inspection_d_exports as PluginInspection, Result };
|
|
5
|
+
}
|
|
6
|
+
export type Result = typeof Result.Type;
|
|
7
|
+
export declare const Result: Schema.Struct<{
|
|
8
|
+
readonly plugin: Schema.NonEmptyString;
|
|
9
|
+
readonly registry: Schema.Unknown;
|
|
10
|
+
readonly sdkVersion: Schema.NonEmptyString;
|
|
11
|
+
readonly version: Schema.NonEmptyString;
|
|
12
|
+
}>;
|
|
13
|
+
export type Output = typeof Output.Type;
|
|
14
|
+
export declare const Output: Schema.Struct<{
|
|
15
|
+
readonly plugin: Schema.NonEmptyString;
|
|
16
|
+
readonly registry: Schema.Unknown;
|
|
17
|
+
readonly sdkVersion: Schema.NonEmptyString;
|
|
18
|
+
readonly version: Schema.NonEmptyString;
|
|
19
|
+
readonly activated: Schema.Literal<false>;
|
|
20
|
+
readonly published: Schema.Literal<false>;
|
|
21
|
+
readonly status: Schema.Literal<"local-only">;
|
|
22
|
+
}>;
|
|
23
|
+
export { inspection_d_exports as PluginInspection };
|
|
24
|
+
//# sourceMappingURL=inspection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspection.d.ts","names":[],"sources":["../../src/plugin/inspection.ts"],"mappings":";;;;;YAEY,gBAAgB,OAAO;qBACtB,QAAM,OAAA;;;;;;YAOP,gBAAgB,OAAO;qBACtB,QAAM,OAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import "./inspection.js";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
// src/plugin/inspection.ts
|
|
5
|
+
var inspection_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
Output: () => Output,
|
|
7
|
+
PluginInspection: () => inspection_exports,
|
|
8
|
+
Result: () => Result
|
|
9
|
+
});
|
|
10
|
+
const Result = Schema.Struct({
|
|
11
|
+
plugin: Schema.NonEmptyString,
|
|
12
|
+
registry: Schema.Unknown,
|
|
13
|
+
sdkVersion: Schema.NonEmptyString,
|
|
14
|
+
version: Schema.NonEmptyString
|
|
15
|
+
});
|
|
16
|
+
const Output = Schema.Struct({
|
|
17
|
+
...Result.fields,
|
|
18
|
+
activated: Schema.Literal(false),
|
|
19
|
+
published: Schema.Literal(false),
|
|
20
|
+
status: Schema.Literal("local-only")
|
|
21
|
+
});
|
|
22
|
+
export { Output, inspection_exports as PluginInspection, Result };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=inspection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspection.js","names":[],"sources":["../../src/plugin/inspection.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nexport type Result = typeof Result.Type;\nexport const Result = Schema.Struct({\n plugin: Schema.NonEmptyString,\n registry: Schema.Unknown,\n sdkVersion: Schema.NonEmptyString,\n version: Schema.NonEmptyString,\n});\n\nexport type Output = typeof Output.Type;\nexport const Output = Schema.Struct({\n ...Result.fields,\n activated: Schema.Literal(false),\n published: Schema.Literal(false),\n status: Schema.Literal(\"local-only\"),\n});\n\nexport * as PluginInspection from \"./inspection.ts\";\n"],"mappings":";;;;;;;;;AAGA,MAAa,SAAS,OAAO,OAAO;CAClC,QAAQ,OAAO;CACf,UAAU,OAAO;CACjB,YAAY,OAAO;CACnB,SAAS,OAAO;AAClB,CAAC;AAGD,MAAa,SAAS,OAAO,OAAO;CAClC,GAAG,OAAO;CACV,WAAW,OAAO,QAAQ,KAAK;CAC/B,WAAW,OAAO,QAAQ,KAAK;CAC/B,QAAQ,OAAO,QAAQ,YAAY;AACrC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import "./package.js";
|
|
2
|
+
import { Context, Effect, FileSystem, Layer, Path, Schema } from "effect";
|
|
3
|
+
declare namespace package_d_exports {
|
|
4
|
+
export { Interface, PackageError, package_d_exports as PluginPackage, Prepared, Service, fromCause, layer };
|
|
5
|
+
}
|
|
6
|
+
declare const PackageError_base: Schema.Class<PackageError, Schema.TaggedStruct<"PackageError", {
|
|
7
|
+
readonly cause: Schema.optionalKey<Schema.Redacted<Schema.Defect>>;
|
|
8
|
+
readonly message: Schema.String;
|
|
9
|
+
}>, import("effect/Cause").YieldableError>;
|
|
10
|
+
export declare class PackageError extends PackageError_base {}
|
|
11
|
+
export declare function fromCause(cause: unknown, context?: string): PackageError;
|
|
12
|
+
export type Prepared = {
|
|
13
|
+
assets: string[];
|
|
14
|
+
directory: string;
|
|
15
|
+
entrypoint: string;
|
|
16
|
+
export: string;
|
|
17
|
+
version: string;
|
|
18
|
+
};
|
|
19
|
+
export type Interface = {
|
|
20
|
+
readonly inspect: (directory: string) => Effect.Effect<Prepared, PackageError>;
|
|
21
|
+
};
|
|
22
|
+
declare const Service_base: Context.ServiceClass<Service, "@dual-os/cli/plugin/package/Service", Interface>;
|
|
23
|
+
export declare class Service extends Service_base {}
|
|
24
|
+
export declare const layer: Layer.Layer<Service, never, FileSystem.FileSystem | Path.Path>;
|
|
25
|
+
export { package_d_exports as PluginPackage };
|
|
26
|
+
//# sourceMappingURL=package.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.d.ts","names":[],"sources":["../../src/plugin/package.ts"],"mappings":";;;;;;;;;qBAmCa,qBAAqB;wBAKlB,UAAU,gBAAgB,mBAAY;YAW1C;EACV;EACA;EACA;EACA;EACA;;YAGU;WACD,UAAU,sBAAsB,OAAO,OAAO,UAAU;;;qBAGtD,gBAAgB;qBAIhB,OAAK,MAAA,MAAA,gBAAA,WAAA,aAAA,KAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import "./package.js";
|
|
3
|
+
import { Array, Context, Effect, FileSystem, Layer, MutableList, Option, Path, Redacted, Schema, String, pipe } from "effect";
|
|
4
|
+
import { Diagnostics } from "#diagnostics";
|
|
5
|
+
import { ReleaseManifest } from "#release/release-manifest";
|
|
6
|
+
// src/plugin/package.ts
|
|
7
|
+
var package_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
+
PackageError: () => PackageError,
|
|
9
|
+
PluginPackage: () => package_exports,
|
|
10
|
+
Service: () => Service,
|
|
11
|
+
fromCause: () => fromCause,
|
|
12
|
+
layer: () => layer
|
|
13
|
+
});
|
|
14
|
+
const RelativePath = Schema.NonEmptyString.check(Schema.isPattern(/^(?!\/|[A-Za-z]:)(?!.*(?:^|\/)\.\.(?:\/|$))[^\\\p{Cc}]+$/u));
|
|
15
|
+
const Manifest = Schema.Struct({
|
|
16
|
+
version: ReleaseManifest.ExactVersion,
|
|
17
|
+
dual: Schema.Struct({ plugin: Schema.Struct({
|
|
18
|
+
assets: Schema.optionalKey(Schema.Array(RelativePath)),
|
|
19
|
+
entrypoint: RelativePath.check(Schema.isPattern(/\.(?:js|mjs|cjs)$/u)),
|
|
20
|
+
export: Schema.NonEmptyString
|
|
21
|
+
}) })
|
|
22
|
+
});
|
|
23
|
+
var PackageError = class extends Schema.TaggedError()("PackageError", {
|
|
24
|
+
cause: Schema.optionalKey(Schema.Redacted(Schema.Defect())),
|
|
25
|
+
message: Schema.String
|
|
26
|
+
}) {};
|
|
27
|
+
function fromCause(cause, context = "") {
|
|
28
|
+
return PackageError.make({
|
|
29
|
+
cause: Redacted.make(cause),
|
|
30
|
+
message: pipe(String.trim(`${context}\n${Diagnostics.format(cause)}`), Option.liftPredicate(String.isNonEmpty), Option.getOrElse(() => "No error details returned by the plugin."))
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
var Service = class extends Context.Service()("@dual-os/cli/plugin/package/Service") {};
|
|
34
|
+
const layer = Layer.effect(Service, Effect.gen(function* () {
|
|
35
|
+
const fs = yield* FileSystem.FileSystem;
|
|
36
|
+
const path = yield* Path.Path;
|
|
37
|
+
const containedPath = Effect.fnUntraced(function* (directory, file) {
|
|
38
|
+
const target = path.resolve(directory, file);
|
|
39
|
+
const relative = path.relative(directory, yield* fs.realPath(target));
|
|
40
|
+
if (path.isAbsolute(relative) || relative === ".." || String.startsWith(`..${path.sep}`)(relative)) return yield* PackageError.make({ message: `Plugin file escapes the package: ${file}` });
|
|
41
|
+
return target;
|
|
42
|
+
});
|
|
43
|
+
return Service.of({ inspect: Effect.fn("PluginPackage.inspect")(function* (directory) {
|
|
44
|
+
const root = yield* fs.realPath(path.resolve(directory));
|
|
45
|
+
const manifest = yield* pipe(Schema.decodeEffect(Schema.fromJsonString(Manifest))(yield* fs.readFileString(path.join(root, "package.json"))), Effect.mapError((cause) => fromCause(cause, "Declare a canonical SemVer version and dual.plugin.entrypoint, export and optional assets in package.json. The entrypoint must be compiled JavaScript and paths must stay inside the package.")));
|
|
46
|
+
const entrypoint = yield* containedPath(root, manifest.dual.plugin.entrypoint);
|
|
47
|
+
if ((yield* fs.stat(entrypoint)).type !== "File") return yield* PackageError.make({ message: "The compiled entrypoint must be a regular file." });
|
|
48
|
+
const assets = MutableList.make();
|
|
49
|
+
for (const pattern of manifest.dual.plugin.assets ?? []) {
|
|
50
|
+
const matches = yield* fs.glob(pattern, { root });
|
|
51
|
+
const files = MutableList.make();
|
|
52
|
+
for (const match of matches) {
|
|
53
|
+
const target = yield* containedPath(root, match);
|
|
54
|
+
const info = yield* fs.stat(target);
|
|
55
|
+
if (info.type === "File") {
|
|
56
|
+
MutableList.append(files, target);
|
|
57
|
+
MutableList.append(assets, target);
|
|
58
|
+
} else if (info.type !== "Directory") return yield* PackageError.make({ message: `Asset is not a regular file: ${match}` });
|
|
59
|
+
}
|
|
60
|
+
if (Array.isReadonlyArrayEmpty(MutableList.toArray(files))) return yield* PackageError.make({ message: `No asset files match: ${pattern}` });
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
assets: MutableList.toArray(assets),
|
|
64
|
+
directory: root,
|
|
65
|
+
entrypoint,
|
|
66
|
+
export: manifest.dual.plugin.export,
|
|
67
|
+
version: manifest.version
|
|
68
|
+
};
|
|
69
|
+
}, Effect.mapError((cause) => Schema.is(PackageError)(cause) ? cause : fromCause(cause))) });
|
|
70
|
+
}));
|
|
71
|
+
export { PackageError, package_exports as PluginPackage, Service, fromCause, layer };
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=package.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.js","names":[],"sources":["../../src/plugin/package.ts"],"sourcesContent":["import {\n Array,\n Context,\n Effect,\n FileSystem,\n Layer,\n MutableList,\n Option,\n Path,\n Redacted,\n Schema,\n String,\n pipe,\n} from \"effect\";\n\nimport { Diagnostics } from \"#diagnostics\";\nimport { ReleaseManifest } from \"#release/release-manifest\";\n\ntype RelativePath = typeof RelativePath.Type;\nconst RelativePath = Schema.NonEmptyString.check(\n Schema.isPattern(/^(?!\\/|[A-Za-z]:)(?!.*(?:^|\\/)\\.\\.(?:\\/|$))[^\\\\\\p{Cc}]+$/u),\n);\n\ntype Manifest = typeof Manifest.Type;\nconst Manifest = Schema.Struct({\n version: ReleaseManifest.ExactVersion,\n dual: Schema.Struct({\n plugin: Schema.Struct({\n assets: Schema.optionalKey(Schema.Array(RelativePath)),\n entrypoint: RelativePath.check(Schema.isPattern(/\\.(?:js|mjs|cjs)$/u)),\n export: Schema.NonEmptyString,\n }),\n }),\n});\n\nexport class PackageError extends Schema.TaggedError<PackageError>()(\"PackageError\", {\n cause: Schema.optionalKey(Schema.Redacted(Schema.Defect())),\n message: Schema.String,\n}) {}\n\nexport function fromCause(cause: unknown, context = \"\") {\n return PackageError.make({\n cause: Redacted.make(cause),\n message: pipe(\n String.trim(`${context}\\n${Diagnostics.format(cause)}`),\n Option.liftPredicate(String.isNonEmpty),\n Option.getOrElse(() => \"No error details returned by the plugin.\"),\n ),\n });\n}\n\nexport type Prepared = {\n assets: string[];\n directory: string;\n entrypoint: string;\n export: string;\n version: string;\n};\n\nexport type Interface = {\n readonly inspect: (directory: string) => Effect.Effect<Prepared, PackageError>;\n};\n\nexport class Service extends Context.Service<Service, Interface>()(\n \"@dual-os/cli/plugin/package/Service\",\n) {}\n\nexport const layer = Layer.effect(\n Service,\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const containedPath = Effect.fnUntraced(function* (directory: string, file: string) {\n const target = path.resolve(directory, file);\n const relative = path.relative(directory, yield* fs.realPath(target));\n if (\n path.isAbsolute(relative) ||\n relative === \"..\" ||\n String.startsWith(`..${path.sep}`)(relative)\n ) {\n return yield* PackageError.make({ message: `Plugin file escapes the package: ${file}` });\n }\n return target;\n });\n return Service.of({\n inspect: Effect.fn(\"PluginPackage.inspect\")(\n function* (directory: string) {\n const root = yield* fs.realPath(path.resolve(directory));\n const manifest = yield* pipe(\n Schema.decodeEffect(Schema.fromJsonString(Manifest))(\n yield* fs.readFileString(path.join(root, \"package.json\")),\n ),\n Effect.mapError(cause =>\n fromCause(\n cause,\n \"Declare a canonical SemVer version and dual.plugin.entrypoint, export and optional assets in package.json. The entrypoint must be compiled JavaScript and paths must stay inside the package.\",\n ),\n ),\n );\n const entrypoint = yield* containedPath(root, manifest.dual.plugin.entrypoint);\n if ((yield* fs.stat(entrypoint)).type !== \"File\") {\n return yield* PackageError.make({\n message: \"The compiled entrypoint must be a regular file.\",\n });\n }\n const assets = MutableList.make<string>();\n for (const pattern of manifest.dual.plugin.assets ?? []) {\n const matches = yield* fs.glob(pattern, { root });\n const files = MutableList.make<string>();\n for (const match of matches) {\n const target = yield* containedPath(root, match);\n const info = yield* fs.stat(target);\n if (info.type === \"File\") {\n MutableList.append(files, target);\n MutableList.append(assets, target);\n } else if (info.type !== \"Directory\") {\n return yield* PackageError.make({\n message: `Asset is not a regular file: ${match}`,\n });\n }\n }\n if (Array.isReadonlyArrayEmpty(MutableList.toArray(files))) {\n return yield* PackageError.make({ message: `No asset files match: ${pattern}` });\n }\n }\n return {\n assets: MutableList.toArray(assets),\n directory: root,\n entrypoint,\n export: manifest.dual.plugin.export,\n version: manifest.version,\n };\n },\n Effect.mapError(cause => (Schema.is(PackageError)(cause) ? cause : fromCause(cause))),\n ),\n });\n }),\n);\n\nexport * as PluginPackage from \"./package.ts\";\n"],"mappings":";;;;;;;;;;;;;AAmBA,MAAM,eAAe,OAAO,eAAe,MACzC,OAAO,UAAU,2DAA2D,CAC9E;AAGA,MAAM,WAAW,OAAO,OAAO;CAC7B,SAAS,gBAAgB;CACzB,MAAM,OAAO,OAAO,EAClB,QAAQ,OAAO,OAAO;EACpB,QAAQ,OAAO,YAAY,OAAO,MAAM,YAAY,CAAC;EACrD,YAAY,aAAa,MAAM,OAAO,UAAU,oBAAoB,CAAC;EACrE,QAAQ,OAAO;CACjB,CAAC,EACH,CAAC;AACH,CAAC;AAED,IAAa,eAAb,cAA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,UACE,OACA,+LACF,CACF,CACF;EACA,MAAM,aAAa,OAAO,cAAc,MAAM,SAAS,KAAK,OAAO,UAAU;EAC7E,KAAK,OAAO,GAAG,KAAK,UAAU,EAAA,CAAG,SAAS,QACxC,OAAO,OAAO,aAAa,KAAK,EAC9B,SAAS,kDACX,CAAC;EAEH,MAAM,SAAS,YAAY,KAAa;EACxC,KAAK,MAAM,WAAW,SAAS,KAAK,OAAO,UAAU,CAAC,GAAG;GACvD,MAAM,UAAU,OAAO,GAAG,KAAK,SAAS,EAAE,KAAK,CAAC;GAChD,MAAM,QAAQ,YAAY,KAAa;GACvC,KAAK,MAAM,SAAS,SAAS;IAC3B,MAAM,SAAS,OAAO,cAAc,MAAM,KAAK;IAC/C,MAAM,OAAO,OAAO,GAAG,KAAK,MAAM;IAClC,IAAI,KAAK,SAAS,QAAQ;KACxB,YAAY,OAAO,OAAO,MAAM;KAChC,YAAY,OAAO,QAAQ,MAAM;IACnC,OAAO,IAAI,KAAK,SAAS,aACvB,OAAO,OAAO,aAAa,KAAK,EAC9B,SAAS,gCAAgC,QAC3C,CAAC;GAEL;GACA,IAAI,MAAM,qBAAqB,YAAY,QAAQ,KAAK,CAAC,GACvD,OAAO,OAAO,aAAa,KAAK,EAAE,SAAS,yBAAyB,UAAU,CAAC;EAEnF;EACA,OAAO;GACL,QAAQ,YAAY,QAAQ,MAAM;GAClC,WAAW;GACX;GACA,QAAQ,SAAS,KAAK,OAAO;GAC7B,SAAS,SAAS;EACpB;CACF,GACA,OAAO,UAAS,UAAU,OAAO,GAAG,YAAY,CAAC,CAAC,KAAK,IAAI,QAAQ,UAAU,KAAK,CAAE,CACtF,EACF,CAAC;AACH,CAAC,CACH"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AuthError, Organizations } from "../auth/protocol.js";
|
|
2
|
+
import { Service as Service$1 } from "../auth/credentials.js";
|
|
3
|
+
import { Service as Service$2, Target } from "../auth/destination.js";
|
|
4
|
+
import { PackageError } from "./package.js";
|
|
5
|
+
import { Service as Service$3 } from "./archive.js";
|
|
6
|
+
import "./publication.js";
|
|
7
|
+
import { Context, Effect, FileSystem, Layer, Path, Schema } from "effect";
|
|
8
|
+
import { HttpClient } from "effect/http";
|
|
9
|
+
declare namespace publication_d_exports {
|
|
10
|
+
export { Interface, publication_d_exports as PluginPublication, Receipt, Service, layer };
|
|
11
|
+
}
|
|
12
|
+
export type Receipt = typeof Receipt.Type;
|
|
13
|
+
export declare const Receipt: Schema.Struct<{
|
|
14
|
+
readonly digest: Schema.String;
|
|
15
|
+
readonly organizationId: Schema.NonEmptyString;
|
|
16
|
+
readonly plugin: Schema.NonEmptyString;
|
|
17
|
+
readonly published: Schema.Literal<true>;
|
|
18
|
+
readonly status: Schema.Literal<"validated">;
|
|
19
|
+
readonly version: Schema.NonEmptyString;
|
|
20
|
+
}>;
|
|
21
|
+
export type Interface = {
|
|
22
|
+
readonly organizations: (deployment: string) => Effect.Effect<Organizations, AuthError>;
|
|
23
|
+
readonly push: (directory: string, target: Target) => Effect.Effect<Receipt, PackageError | AuthError>;
|
|
24
|
+
};
|
|
25
|
+
declare const Service_base: Context.ServiceClass<Service, "@dual-os/cli/plugin/publication/Service", Interface>;
|
|
26
|
+
export declare class Service extends Service_base {}
|
|
27
|
+
export declare const layer: Layer.Layer<Service, never, FileSystem.FileSystem | HttpClient.HttpClient | Path.Path | Service$1 | Service$2 | Service$3>;
|
|
28
|
+
export { publication_d_exports as PluginPublication };
|
|
29
|
+
//# sourceMappingURL=publication.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publication.d.ts","names":["AuthProtocol.Organizations","AuthProtocol.AuthError","CliDestination.Target","PluginPackage.PackageError","CliCredentials.Service","CliDestination.Service","PluginArchive.Service"],"sources":["../../src/plugin/publication.ts"],"mappings":";;;;;;;;;;;YAsBY,iBAAiB,QAAQ;qBACxB,SAAO,OAAA;;;;;;;;YAQR;WACD,gBACP,uBACG,OAAO,OAAOA,eAA4BC;WACtC,OACP,mBACA,QAAQC,WACL,OAAO,OAAO,SAASC,eAA6BF;;;qBAE9C,gBAAgB;qBAGhB,OAAK,MAAA,MAAA,gBAAA,WAAA,aAAA,WAAA,aAAA,KAAA,OAAAG,YAAAC,YAAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { PackageError, fromCause } from "./package.js";
|
|
3
|
+
import { Service as Service$1 } from "./archive.js";
|
|
4
|
+
import "./publication.js";
|
|
5
|
+
import { Context, Effect, FileSystem, Inspectable, Layer, Path, Redacted, Schema, pipe } from "effect";
|
|
6
|
+
import { HttpClient, HttpClientRequest } from "effect/http";
|
|
7
|
+
import { CliCredentials } from "#auth/credentials";
|
|
8
|
+
import { CliDestination } from "#auth/destination";
|
|
9
|
+
import { CliHttp } from "#auth/http";
|
|
10
|
+
import { AuthProtocol } from "#auth/protocol";
|
|
11
|
+
// src/plugin/publication.ts
|
|
12
|
+
var publication_exports = /* @__PURE__ */ __exportAll({
|
|
13
|
+
PluginPublication: () => publication_exports,
|
|
14
|
+
Receipt: () => Receipt,
|
|
15
|
+
Service: () => Service,
|
|
16
|
+
layer: () => layer
|
|
17
|
+
});
|
|
18
|
+
const Receipt = Schema.Struct({
|
|
19
|
+
digest: Schema.String.check(Schema.isPattern(/^[a-f0-9]{128}$/u)),
|
|
20
|
+
organizationId: Schema.NonEmptyString,
|
|
21
|
+
plugin: Schema.NonEmptyString,
|
|
22
|
+
published: Schema.Literal(true),
|
|
23
|
+
status: Schema.Literal("validated"),
|
|
24
|
+
version: Schema.NonEmptyString
|
|
25
|
+
});
|
|
26
|
+
var Service = class extends Context.Service()("@dual-os/cli/plugin/publication/Service") {};
|
|
27
|
+
const layer = Layer.effect(Service, Effect.gen(function* () {
|
|
28
|
+
const fs = yield* FileSystem.FileSystem;
|
|
29
|
+
const path = yield* Path.Path;
|
|
30
|
+
const client = CliHttp.withErrors(yield* HttpClient.HttpClient);
|
|
31
|
+
const credentials = yield* CliCredentials.Service;
|
|
32
|
+
const archives = yield* Service$1;
|
|
33
|
+
const destination = yield* CliDestination.Service;
|
|
34
|
+
const mapError = Effect.mapError((cause) => Schema.is(AuthProtocol.AuthError)(cause) || Schema.is(PackageError)(cause) ? cause : fromCause(cause));
|
|
35
|
+
return Service.of({
|
|
36
|
+
organizations: Effect.fn("PluginPublication.organizations")(function* (deployment) {
|
|
37
|
+
const credential = Redacted.value(yield* credentials.get(deployment));
|
|
38
|
+
const response = yield* client.execute(pipe(HttpClientRequest.get(new URL("/api/cli-auth/organizations", deployment).href), HttpClientRequest.bearerToken(credential.token)));
|
|
39
|
+
yield* CliHttp.requireStatus(response, [200]);
|
|
40
|
+
return yield* Schema.decodeUnknownEffect(AuthProtocol.Organizations)(yield* pipe(response.json, Effect.mapError(CliHttp.fromCause)));
|
|
41
|
+
}, Effect.scoped, Effect.mapError((cause) => Schema.is(AuthProtocol.AuthError)(cause) ? cause : AuthProtocol.AuthError.make({
|
|
42
|
+
cause: Redacted.make(cause),
|
|
43
|
+
message: Inspectable.toStringUnknown(cause)
|
|
44
|
+
}))),
|
|
45
|
+
push: Effect.fn("PluginPublication.push")(function* (directory, target) {
|
|
46
|
+
const credential = Redacted.value(yield* credentials.get(target.deployment));
|
|
47
|
+
const file = path.join(yield* fs.makeTempDirectoryScoped({ prefix: "dual-plugin-push-" }), "plugin.tgz");
|
|
48
|
+
const artifact = yield* archives.build(directory, file);
|
|
49
|
+
const response = yield* client.execute(pipe(HttpClientRequest.post(new URL("/api/cli/plugins/push", target.deployment).href), HttpClientRequest.bearerToken(credential.token), HttpClientRequest.setHeaders({
|
|
50
|
+
"x-dual-artifact-sha512": artifact.digest,
|
|
51
|
+
"x-dual-organization-id": target.organizationId,
|
|
52
|
+
"x-dual-plugin-key": artifact.plugin,
|
|
53
|
+
"x-dual-plugin-version": artifact.version
|
|
54
|
+
}), HttpClientRequest.bodyUint8Array(yield* fs.readFile(file), "application/gzip")));
|
|
55
|
+
yield* CliHttp.requireStatus(response, [200, 201]);
|
|
56
|
+
const receipt = yield* Schema.decodeUnknownEffect(Receipt)(yield* pipe(response.json, Effect.mapError(CliHttp.fromCause)));
|
|
57
|
+
if (receipt.digest !== artifact.digest || receipt.plugin !== artifact.plugin || receipt.version !== artifact.version || receipt.organizationId !== target.organizationId) return yield* AuthProtocol.AuthError.make({ message: "Dual returned a different artifact identity. No publication success was confirmed." });
|
|
58
|
+
yield* destination.save(directory, target);
|
|
59
|
+
return receipt;
|
|
60
|
+
}, Effect.scoped, mapError)
|
|
61
|
+
});
|
|
62
|
+
}));
|
|
63
|
+
export { publication_exports as PluginPublication, Receipt, Service, layer };
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=publication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publication.js","names":["PluginArchive.Service","PluginPackage.PackageError","PluginPackage.fromCause"],"sources":["../../src/plugin/publication.ts"],"sourcesContent":["import {\n Context,\n Effect,\n FileSystem,\n Inspectable,\n Layer,\n Path,\n Redacted,\n Schema,\n pipe,\n} from \"effect\";\n\nimport { HttpClient, HttpClientRequest } from \"effect/http\";\n\nimport { CliCredentials } from \"#auth/credentials\";\nimport { CliDestination } from \"#auth/destination\";\nimport { CliHttp } from \"#auth/http\";\nimport { AuthProtocol } from \"#auth/protocol\";\n\nimport { PluginArchive } from \"./archive.ts\";\nimport { PluginPackage } from \"./package.ts\";\n\nexport type Receipt = typeof Receipt.Type;\nexport const Receipt = Schema.Struct({\n digest: Schema.String.check(Schema.isPattern(/^[a-f0-9]{128}$/u)),\n organizationId: Schema.NonEmptyString,\n plugin: Schema.NonEmptyString,\n published: Schema.Literal(true),\n status: Schema.Literal(\"validated\"),\n version: Schema.NonEmptyString,\n});\nexport type Interface = {\n readonly organizations: (\n deployment: string,\n ) => Effect.Effect<AuthProtocol.Organizations, AuthProtocol.AuthError>;\n readonly push: (\n directory: string,\n target: CliDestination.Target,\n ) => Effect.Effect<Receipt, PluginPackage.PackageError | AuthProtocol.AuthError>;\n};\nexport class Service extends Context.Service<Service, Interface>()(\n \"@dual-os/cli/plugin/publication/Service\",\n) {}\nexport const layer = Layer.effect(\n Service,\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const client = CliHttp.withErrors(yield* HttpClient.HttpClient);\n const credentials = yield* CliCredentials.Service;\n const archives = yield* PluginArchive.Service;\n const destination = yield* CliDestination.Service;\n const mapError = Effect.mapError(cause =>\n Schema.is(AuthProtocol.AuthError)(cause) || Schema.is(PluginPackage.PackageError)(cause)\n ? cause\n : PluginPackage.fromCause(cause),\n );\n return Service.of({\n organizations: Effect.fn(\"PluginPublication.organizations\")(\n function* (deployment) {\n const credential = Redacted.value(yield* credentials.get(deployment));\n const response = yield* client.execute(\n pipe(\n HttpClientRequest.get(new URL(\"/api/cli-auth/organizations\", deployment).href),\n HttpClientRequest.bearerToken(credential.token),\n ),\n );\n yield* CliHttp.requireStatus(response, [200]);\n return yield* Schema.decodeUnknownEffect(AuthProtocol.Organizations)(\n yield* pipe(response.json, Effect.mapError(CliHttp.fromCause)),\n );\n },\n Effect.scoped,\n Effect.mapError(cause =>\n Schema.is(AuthProtocol.AuthError)(cause)\n ? cause\n : AuthProtocol.AuthError.make({\n cause: Redacted.make(cause),\n message: Inspectable.toStringUnknown(cause),\n }),\n ),\n ),\n push: Effect.fn(\"PluginPublication.push\")(\n function* (directory, target) {\n const credential = Redacted.value(yield* credentials.get(target.deployment));\n const file = path.join(\n yield* fs.makeTempDirectoryScoped({ prefix: \"dual-plugin-push-\" }),\n \"plugin.tgz\",\n );\n const artifact = yield* archives.build(directory, file);\n const response = yield* client.execute(\n pipe(\n HttpClientRequest.post(new URL(\"/api/cli/plugins/push\", target.deployment).href),\n HttpClientRequest.bearerToken(credential.token),\n HttpClientRequest.setHeaders({\n \"x-dual-artifact-sha512\": artifact.digest,\n \"x-dual-organization-id\": target.organizationId,\n \"x-dual-plugin-key\": artifact.plugin,\n \"x-dual-plugin-version\": artifact.version,\n }),\n HttpClientRequest.bodyUint8Array(yield* fs.readFile(file), \"application/gzip\"),\n ),\n );\n yield* CliHttp.requireStatus(response, [200, 201]);\n const receipt = yield* Schema.decodeUnknownEffect(Receipt)(\n yield* pipe(response.json, Effect.mapError(CliHttp.fromCause)),\n );\n if (\n receipt.digest !== artifact.digest ||\n receipt.plugin !== artifact.plugin ||\n receipt.version !== artifact.version ||\n receipt.organizationId !== target.organizationId\n ) {\n return yield* AuthProtocol.AuthError.make({\n message:\n \"Dual returned a different artifact identity. No publication success was confirmed.\",\n });\n }\n yield* destination.save(directory, target);\n return receipt;\n },\n Effect.scoped,\n mapError,\n ),\n });\n }),\n);\nexport * as PluginPublication from \"./publication.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,MAAa,UAAU,OAAO,OAAO;CACnC,QAAQ,OAAO,OAAO,MAAM,OAAO,UAAU,kBAAkB,CAAC;CAChE,gBAAgB,OAAO;CACvB,QAAQ,OAAO;CACf,WAAW,OAAO,QAAQ,IAAI;CAC9B,QAAQ,OAAO,QAAQ,WAAW;CAClC,SAAS,OAAO;AAClB,CAAC;AAUD,IAAa,UAAb,cAA6B,QAAQ,QAA4B,CAAC,CAChE,yCACF,CAAC,CAAC,CAAC;AACH,MAAa,QAAQ,MAAM,OACzB,SACA,OAAO,IAAI,aAAa;CACtB,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,SAAS,QAAQ,WAAW,OAAO,WAAW,UAAU;CAC9D,MAAM,cAAc,OAAO,eAAe;CAC1C,MAAM,WAAW,OAAOA;CACxB,MAAM,cAAc,OAAO,eAAe;CAC1C,MAAM,WAAW,OAAO,UAAS,UAC/B,OAAO,GAAG,aAAa,SAAS,CAAC,CAAC,KAAK,KAAK,OAAO,GAAGC,YAA0B,CAAC,CAAC,KAAK,IACnF,QACAC,UAAwB,KAAK,CACnC;CACA,OAAO,QA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;GACA,OAAO,QAAQ,cAAc,UAAU,CAAC,KAAK,GAAG,CAAC;GACjD,MAAM,UAAU,OAAO,OAAO,oBAAoB,OAAO,CAAC,CACxD,OAAO,KAAK,SAAS,MAAM,OAAO,SAAS,QAAQ,SAAS,CAAC,CAC/D;GACA,IACE,QAAQ,WAAW,SAAS,UAC5B,QAAQ,WAAW,SAAS,UAC5B,QAAQ,YAAY,SAAS,WAC7B,QAAQ,mBAAmB,OAAO,gBAElC,OAAO,OAAO,aAAa,UAAU,KAAK,EACxC,SACE,qFACJ,CAAC;GAEH,OAAO,YAAY,KAAK,WAAW,MAAM;GACzC,OAAO;EACT,GACA,OAAO,QACP,QACF;CACF,CAAC;AACH,CAAC,CACH"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PackageError, Service as Service$1 } from "./package.js";
|
|
2
|
+
import { Result as Result$1 } from "./inspection.js";
|
|
3
|
+
import "./validation.js";
|
|
4
|
+
import { Context, Effect, FileSystem, Layer, Path } from "effect";
|
|
5
|
+
import { ChildProcessSpawner } from "effect/process";
|
|
6
|
+
declare namespace validation_d_exports {
|
|
7
|
+
export { validation_d_exports as PluginValidation, Service, layer };
|
|
8
|
+
}
|
|
9
|
+
declare const Service_base: Context.ServiceClass<Service, "@dual-os/cli/plugin/validation/Service", {
|
|
10
|
+
readonly validate: (directory: string) => Effect.Effect<Result$1, PackageError>;
|
|
11
|
+
}>;
|
|
12
|
+
export declare class Service extends Service_base {}
|
|
13
|
+
export declare const layer: Layer.Layer<Service, never, ChildProcessSpawner.ChildProcessSpawner | FileSystem.FileSystem | Path.Path | Service$1>;
|
|
14
|
+
export { validation_d_exports as PluginValidation };
|
|
15
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","names":["PluginInspection.Result","PluginPackage.PackageError","PluginPackage.Service"],"sources":["../../src/plugin/validation.ts"],"mappings":";;;;;;;;;WA+BuB,WACjB,sBACG,OAAO,OAAOA,UAAyBC;;qBALnC,gBAAgB;qBAShB,OAAK,MAAA,MAAA,gBAAA,oBAAA,sBAAA,WAAA,aAAA,KAAA,OAAAC"}
|