-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cf-workers): add cloudflare-workers package
- Loading branch information
1 parent
e9bab52
commit fff47c8
Showing
30 changed files
with
4,315 additions
and
161 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"executors": { | ||
"build": { | ||
"implementation": "./src/executors/build/executor", | ||
"schema": "./src/executors/build/schema.json", | ||
"description": "build executor" | ||
"serve": { | ||
"implementation": "./src/executors/serve/serve", | ||
"schema": "./src/executors/serve/schema.json", | ||
"description": "serve executor" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
packages/cloudflare/workers/src/executors/build/executor.spec.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export interface ServeExecutorSchema {} // eslint-disable-line |
2 changes: 1 addition & 1 deletion
2
...e/workers/src/executors/build/schema.json → ...e/workers/src/executors/serve/schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ServeExecutorSchema } from './schema'; | ||
|
||
export default async function runExecutor( | ||
options: ServeExecutorSchema, | ||
) { | ||
console.log('Executor ran for Serve', options) | ||
|
||
return { | ||
success: true | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/cloudflare/workers/src/generators/init/generator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { | ||
addDependenciesToPackageJson, | ||
Tree, | ||
} from '@nrwl/devkit'; | ||
|
||
export function workerInit(tree: Tree) { | ||
const installTask = addDependenciesToPackageJson(tree, {tslib: '^2.4.0'}, { | ||
"@nrwl/js": "14.1.7", | ||
"wrangler": "^2.0.2", | ||
"@cloudflare/workers-types": "^3.10.0" | ||
}) | ||
|
||
return () => { | ||
installTask(); | ||
} | ||
} | ||
|
||
export default workerInit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface InitGeneratorSchema { | ||
name: string; | ||
tags?: string; | ||
directory?: string; | ||
} |
29 changes: 29 additions & 0 deletions
29
packages/cloudflare/workers/src/generators/init/schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"cli": "nx", | ||
"$id": "Init", | ||
"title": "", | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string", | ||
"description": "", | ||
"$default": { | ||
"$source": "argv", | ||
"index": 0 | ||
}, | ||
"x-prompt": "What name would you like to use?" | ||
}, | ||
"tags": { | ||
"type": "string", | ||
"description": "Add tags to the project (used for linting)", | ||
"alias": "t" | ||
}, | ||
"directory": { | ||
"type": "string", | ||
"description": "A directory where the project is placed", | ||
"alias": "d" | ||
} | ||
}, | ||
"required": ["name"] | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface KvGeneratorSchema { | ||
name: string; | ||
tags?: string; | ||
directory?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"cli": "nx", | ||
"$id": "Kv", | ||
"title": "", | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string", | ||
"description": "", | ||
"$default": { | ||
"$source": "argv", | ||
"index": 0 | ||
}, | ||
"x-prompt": "What name would you like to use?" | ||
}, | ||
"tags": { | ||
"type": "string", | ||
"description": "Add tags to the project (used for linting)", | ||
"alias": "t" | ||
}, | ||
"directory": { | ||
"type": "string", | ||
"description": "A directory where the project is placed", | ||
"alias": "d" | ||
} | ||
}, | ||
"required": ["name"] | ||
} |
31 changes: 31 additions & 0 deletions
31
packages/cloudflare/workers/src/generators/worker/__snapshots__/worker.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`cloudflare-workers generator should generate files 1`] = ` | ||
"name = \\"my-worker-app\\" | ||
compatibility_date = \\"2022-05-20\\" | ||
[env.dev] | ||
kv_namespaces = [] | ||
[env.production] | ||
kv_namespaces = [] | ||
" | ||
`; | ||
|
||
exports[`cloudflare-workers generator should generate files 2`] = ` | ||
Object { | ||
"configurations": Object { | ||
"production": Object { | ||
"commands": Array [ | ||
"npx wrangler dev src/index.ts --tsconfig.json=tsconfig.lib.json --env=production", | ||
], | ||
}, | ||
}, | ||
"executor": "@nrwl/workspace:run-commands", | ||
"options": Object { | ||
"commands": Array [ | ||
"npx wrangler dev src/index.ts --tsconfig.json=tsconfig.lib.json --env=dev", | ||
], | ||
"cwd": "libs/my-worker-app", | ||
}, | ||
} | ||
`; |
Oops, something went wrong.