@celsoft/platform 0.0.0-stage → 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/LICENSE +21 -0
- package/dist/adapters/cloudflare.d.ts +14 -0
- package/dist/adapters/cloudflare.js +78 -0
- package/dist/adapters/cloudflare.js.map +1 -0
- package/dist/adapters/github.d.ts +10 -0
- package/dist/adapters/github.js +47 -0
- package/dist/adapters/github.js.map +1 -0
- package/dist/adapters/neon.d.ts +11 -0
- package/dist/adapters/neon.js +49 -0
- package/dist/adapters/neon.js.map +1 -0
- package/dist/adapters/process.d.ts +14 -0
- package/dist/adapters/process.js +46 -0
- package/dist/adapters/process.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +157 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +25 -0
- package/dist/config.js +98 -0
- package/dist/config.js.map +1 -0
- package/dist/fakes.d.ts +53 -0
- package/dist/fakes.js +89 -0
- package/dist/fakes.js.map +1 -0
- package/dist/init.d.ts +19 -0
- package/dist/init.js +96 -0
- package/dist/init.js.map +1 -0
- package/dist/lifecycle.d.ts +19 -0
- package/dist/lifecycle.js +89 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/ports.d.ts +49 -0
- package/dist/ports.js +2 -0
- package/dist/ports.js.map +1 -0
- package/dist/run.d.ts +9 -0
- package/dist/run.js +29 -0
- package/dist/run.js.map +1 -0
- package/dist/runtime/index.d.ts +22 -0
- package/dist/runtime/index.js +29 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/secrets.d.ts +5 -0
- package/dist/secrets.js +42 -0
- package/dist/secrets.js.map +1 -0
- package/dist/target.d.ts +15 -0
- package/dist/target.js +15 -0
- package/dist/target.js.map +1 -0
- package/dist/workflow.d.ts +9 -0
- package/dist/workflow.js +48 -0
- package/dist/workflow.js.map +1 -0
- package/dist/wrangler-config.d.ts +9 -0
- package/dist/wrangler-config.js +17 -0
- package/dist/wrangler-config.js.map +1 -0
- package/dist/write-schema.d.ts +1 -0
- package/dist/write-schema.js +4 -0
- package/dist/write-schema.js.map +1 -0
- package/package.json +32 -4
- package/schema.json +105 -0
- package/README.md +0 -3
package/dist/target.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function names(config, target) {
|
|
2
|
+
if (target.kind === "prod") {
|
|
3
|
+
return { worker: config.name, hyperdrive: config.name, neonBranch: undefined };
|
|
4
|
+
}
|
|
5
|
+
const suffix = `pr-${target.pr}`;
|
|
6
|
+
return { worker: `${config.name}-${suffix}`, hyperdrive: `${config.name}-${suffix}`, neonBranch: suffix };
|
|
7
|
+
}
|
|
8
|
+
export function previewHostname(worker, zoneName) {
|
|
9
|
+
return `${worker}.${zoneName}`;
|
|
10
|
+
}
|
|
11
|
+
export function originOf(connectionUri) {
|
|
12
|
+
const url = new URL(connectionUri);
|
|
13
|
+
return `${url.username}@${url.host}${url.pathname}`;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=target.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"target.js","sourceRoot":"","sources":["../src/target.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,KAAK,CAAC,MAAc,EAAE,MAAc;IAClD,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;IACjF,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,EAAE,EAAE,CAAC;IACjC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,EAAE,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;AAC5G,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAc,EAAE,QAAgB;IAC9D,OAAO,GAAG,MAAM,IAAI,QAAQ,EAAE,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,aAAqB;IAC5C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC;IACnC,OAAO,GAAG,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const WORKFLOW_PATH = ".github/workflows/platform.yml";
|
|
2
|
+
export type PackageManager = "pnpm" | "npm";
|
|
3
|
+
export interface WorkflowInput {
|
|
4
|
+
appDir: string;
|
|
5
|
+
packageManager: PackageManager;
|
|
6
|
+
secrets: string[];
|
|
7
|
+
variables: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare function renderWorkflow({ appDir, packageManager, secrets, variables }: WorkflowInput): string;
|
package/dist/workflow.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export const WORKFLOW_PATH = ".github/workflows/platform.yml";
|
|
2
|
+
// Written by `platform init` and compared by `platform ci`, so it must stay deterministic.
|
|
3
|
+
// Each secret and variable is passed by name, so the step only ever sees what the app uses.
|
|
4
|
+
export function renderWorkflow({ appDir, packageManager, secrets, variables }) {
|
|
5
|
+
const install = packageManager === "pnpm" ? "pnpm install --frozen-lockfile" : "npm ci";
|
|
6
|
+
const exec = packageManager === "pnpm" ? "pnpm exec platform ci" : "npx --no-install platform ci";
|
|
7
|
+
const setupPnpm = packageManager === "pnpm" ? "\n - uses: pnpm/action-setup@v4" : "";
|
|
8
|
+
const workingDirectory = appDir === "." ? "" : `\n working-directory: ${appDir}`;
|
|
9
|
+
const env = [
|
|
10
|
+
...[...new Set(secrets)].sort().map((name) => `${name}: \${{ secrets.${name} }}`),
|
|
11
|
+
...[...new Set(variables)].sort().map((name) => `${name}: \${{ vars.${name} }}`),
|
|
12
|
+
"GITHUB_TOKEN: ${{ github.token }}",
|
|
13
|
+
];
|
|
14
|
+
return `# Written by \`platform init\`; rerun it to update this file.
|
|
15
|
+
name: platform
|
|
16
|
+
|
|
17
|
+
on:
|
|
18
|
+
push:
|
|
19
|
+
branches: [main]
|
|
20
|
+
pull_request:
|
|
21
|
+
types: [opened, synchronize, reopened, closed]
|
|
22
|
+
|
|
23
|
+
concurrency:
|
|
24
|
+
group: platform-\${{ github.event.pull_request.number || github.ref }}
|
|
25
|
+
cancel-in-progress: \${{ github.event_name == 'pull_request' }}
|
|
26
|
+
|
|
27
|
+
permissions:
|
|
28
|
+
contents: read
|
|
29
|
+
pull-requests: write
|
|
30
|
+
|
|
31
|
+
jobs:
|
|
32
|
+
platform:
|
|
33
|
+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
environment: \${{ github.event_name == 'push' && 'production' || 'preview' }}
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v5${setupPnpm}
|
|
38
|
+
- uses: actions/setup-node@v5
|
|
39
|
+
with:
|
|
40
|
+
node-version: 24
|
|
41
|
+
cache: ${packageManager}
|
|
42
|
+
- run: ${install}
|
|
43
|
+
- run: ${exec}${workingDirectory}
|
|
44
|
+
env:
|
|
45
|
+
${env.map((line) => ` ${line}`).join("\n")}
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,gCAAgC,CAAC;AAW9D,2FAA2F;AAC3F,4FAA4F;AAC5F,MAAM,UAAU,cAAc,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,EAAiB;IAC1F,MAAM,OAAO,GAAG,cAAc,KAAK,MAAM,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACxF,MAAM,IAAI,GAAG,cAAc,KAAK,MAAM,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,8BAA8B,CAAC;IAClG,MAAM,SAAS,GAAG,cAAc,KAAK,MAAM,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1F,MAAM,gBAAgB,GAAG,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gCAAgC,MAAM,EAAE,CAAC;IACxF,MAAM,GAAG,GAAG;QACV,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,kBAAkB,IAAI,KAAK,CAAC;QACjF,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,eAAe,IAAI,KAAK,CAAC;QAChF,mCAAmC;KACpC,CAAC;IAEF,OAAO;;;;;;;;;;;;;;;;;;;;;;;mCAuB0B,SAAS;;;;mBAIzB,cAAc;eAClB,OAAO;eACP,IAAI,GAAG,gBAAgB;;EAEpC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;CAClD,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Config } from "./config.js";
|
|
2
|
+
export interface WranglerInput {
|
|
3
|
+
config: Config;
|
|
4
|
+
worker: string;
|
|
5
|
+
hostname: string;
|
|
6
|
+
accountId: string;
|
|
7
|
+
hyperdriveId: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare function wranglerConfig({ config, worker, hostname, accountId, hyperdriveId }: WranglerInput): object;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function wranglerConfig({ config, worker, hostname, accountId, hyperdriveId }) {
|
|
2
|
+
return {
|
|
3
|
+
name: worker,
|
|
4
|
+
account_id: accountId,
|
|
5
|
+
main: config.worker,
|
|
6
|
+
compatibility_date: config.compatibilityDate,
|
|
7
|
+
compatibility_flags: ["nodejs_compat"],
|
|
8
|
+
workers_dev: false,
|
|
9
|
+
routes: [{ pattern: hostname, custom_domain: true }],
|
|
10
|
+
observability: { enabled: true },
|
|
11
|
+
...(config.frontend && {
|
|
12
|
+
assets: { directory: config.frontend, not_found_handling: "single-page-application", run_worker_first: ["/api/*"] },
|
|
13
|
+
}),
|
|
14
|
+
...(hyperdriveId && { hyperdrive: [{ binding: "DB", id: hyperdriveId }] }),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=wrangler-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrangler-config.js","sourceRoot":"","sources":["../src/wrangler-config.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,cAAc,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAiB;IACjG,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE,MAAM,CAAC,MAAM;QACnB,kBAAkB,EAAE,MAAM,CAAC,iBAAiB;QAC5C,mBAAmB,EAAE,CAAC,eAAe,CAAC;QACtC,WAAW,EAAE,KAAK;QAClB,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;QACpD,aAAa,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAChC,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI;YACrB,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,QAAQ,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,CAAC,QAAQ,CAAC,EAAE;SACpH,CAAC;QACF,GAAG,CAAC,YAAY,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;KAC3E,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-schema.js","sourceRoot":"","sources":["../src/write-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,SAAS,CAAC,IAAI,GAAG,CAAC,gBAAgB,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celsoft/platform",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
}
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Deploy apps to Cloudflare Workers with Neon Postgres, prod on push and a preview per pull request",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": { "type": "git", "url": "git+https://github.com/celsoft-com/platform.git", "directory": "packages/platform" },
|
|
7
|
+
"homepage": "https://github.com/celsoft-com/platform#readme",
|
|
8
|
+
"publishConfig": { "access": "public" },
|
|
9
|
+
"type": "module",
|
|
10
|
+
"bin": {
|
|
11
|
+
"platform": "./dist/cli.js"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": "./dist/runtime/index.js"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"schema.json"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"prepare": "tsc -b && node dist/write-schema.js"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@neondatabase/api-client": "^2.7.3",
|
|
25
|
+
"cloudflare": "^7.3.0",
|
|
26
|
+
"jsonc-parser": "^3.3.1",
|
|
27
|
+
"postgres": "^3.4.9",
|
|
28
|
+
"wrangler": "^4.152.0",
|
|
29
|
+
"zod": "^4.6.7"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"typescript": "7.0.2"
|
|
33
|
+
}
|
|
34
|
+
}
|
package/schema.json
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"$schema": {
|
|
6
|
+
"type": "string"
|
|
7
|
+
},
|
|
8
|
+
"version": {
|
|
9
|
+
"type": "number",
|
|
10
|
+
"const": 1
|
|
11
|
+
},
|
|
12
|
+
"name": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"anyOf": [
|
|
15
|
+
{
|
|
16
|
+
"pattern": "^[a-z][a-z0-9-]{0,49}$"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"pattern": "^\\$\\{[A-Z][A-Z0-9_]*\\}$"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"hostname": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"anyOf": [
|
|
26
|
+
{
|
|
27
|
+
"pattern": "^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]{2,63}$"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"pattern": "^\\$\\{[A-Z][A-Z0-9_]*\\}$"
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
"worker": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"minLength": 1,
|
|
37
|
+
"description": "Path to the Worker's entry module, relative to platform.jsonc"
|
|
38
|
+
},
|
|
39
|
+
"compatibilityDate": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"anyOf": [
|
|
42
|
+
{
|
|
43
|
+
"pattern": "^\\d{4}-\\d{2}-\\d{2}$"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"pattern": "^\\$\\{[A-Z][A-Z0-9_]*\\}$"
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"frontend": {
|
|
51
|
+
"description": "Directory holding the built static files",
|
|
52
|
+
"type": "string",
|
|
53
|
+
"minLength": 1
|
|
54
|
+
},
|
|
55
|
+
"database": {
|
|
56
|
+
"type": "object",
|
|
57
|
+
"properties": {
|
|
58
|
+
"neonProject": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"anyOf": [
|
|
61
|
+
{
|
|
62
|
+
"pattern": "^[a-z]+-[a-z]+-\\d+$"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"pattern": "^\\$\\{[A-Z][A-Z0-9_]*\\}$"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
"migrate": {
|
|
70
|
+
"type": "string",
|
|
71
|
+
"minLength": 1,
|
|
72
|
+
"description": "Command that runs migrations against $DATABASE_URL"
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"required": [
|
|
76
|
+
"neonProject",
|
|
77
|
+
"migrate"
|
|
78
|
+
],
|
|
79
|
+
"additionalProperties": false
|
|
80
|
+
},
|
|
81
|
+
"secrets": {
|
|
82
|
+
"default": [],
|
|
83
|
+
"type": "array",
|
|
84
|
+
"items": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
"anyOf": [
|
|
87
|
+
{
|
|
88
|
+
"pattern": "^[A-Z][A-Z0-9_]*$"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"pattern": "^\\$\\{[A-Z][A-Z0-9_]*\\}$"
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"required": [
|
|
98
|
+
"version",
|
|
99
|
+
"name",
|
|
100
|
+
"hostname",
|
|
101
|
+
"worker",
|
|
102
|
+
"compatibilityDate"
|
|
103
|
+
],
|
|
104
|
+
"additionalProperties": false
|
|
105
|
+
}
|
package/README.md
DELETED