Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated everything #27

Merged
merged 11 commits into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest']
node: ['12.x']
deno: ['0.42.0']
node: ['14.x']
deno: ['1.3.2']
fail-fast: false
runs-on: ${{ matrix.os }}
name: build-${{ matrix.os }}
Expand Down Expand Up @@ -43,8 +43,8 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
node: ['12.x']
deno: ['0.42.0']
node: ['14.x']
deno: ['1.3.2']
fail-fast: false
runs-on: ${{ matrix.os }}
name: test-${{ matrix.os }}
Expand All @@ -61,12 +61,12 @@ jobs:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: yarn install
- name: Install now
run: npm i -g now
- name: Install vercel
run: npm i -g vercel
if: matrix.os == 'windows-latest'
- name: Update package version and tag
run: deno run --unstable --allow-env --allow-read --allow-write .github/workflows/update-version.ts
- name: Run tests
run: deno test --unstable --allow-env --allow-write --allow-net --allow-run .github/workflows/tests.ts
run: deno test --unstable --allow-env --allow-read --allow-write --allow-net --allow-run .github/workflows/tests.ts
env:
NOW_TOKEN: ${{ secrets.NOW_TOKEN }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
36 changes: 18 additions & 18 deletions .github/workflows/tests.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {
assert,
assertStrContains,
} from 'https://deno.land/std@v0.42.0/testing/asserts.ts';
import { join } from 'https://deno.land/std@v0.42.0/path/mod.ts';
assertStringContains
} from 'https://deno.land/std@0.68.0/testing/asserts.ts';
import { join } from 'https://deno.land/std@0.68.0/path/mod.ts';

const isWin = Deno.build.os == 'windows';
const runNow = isWin ? ['now.cmd'] : ['npx', 'now'];
const runNow = isWin ? ['vercel.cmd'] : ['npx', 'vercel'];

Deno.test({
name: 'deploy to now',
name: 'deploy to vercel',
async fn() {
const proc = Deno.run({
cmd: runNow.concat('-c', '-f', '-t', Deno.env.get('NOW_TOKEN')!),
cmd: runNow.concat('-c', '-f', '-t', Deno.env.get('VERCEL_TOKEN')!),
cwd: join(Deno.cwd(), 'example'),
stdout: 'piped',
stderr: 'piped',
Expand All @@ -26,20 +26,20 @@ Deno.test({
const req = await fetch(`${url}/api/version`);
assert(req.ok);
const text = await req.text();
assertStrContains(text, 'Welcome to deno');
assertStrContains(text, '🦕');
assertStringContains(text, 'Welcome to deno');
assertStringContains(text, '🦕');
},
});

Deno.test({
name: 'deploy to now with specific version',
name: 'deploy to vercel with specific version',
async fn() {
const proc = Deno.run({
cmd: runNow.concat(
'-c',
'-f',
'-t',
Deno.env.get('NOW_TOKEN')!,
Deno.env.get('VERCEL_TOKEN')!,
'--build-env',
'DENO_VERSION=0.40.0'
),
Expand All @@ -57,19 +57,19 @@ Deno.test({
const req = await fetch(`${url}/api/version`);
assert(req.ok);
const text = await req.text();
assertStrContains(text, 'Welcome to deno');
assertStrContains(text, '0.40.0');
assertStrContains(text, '🦕');
assertStringContains(text, 'Welcome to deno');
assertStringContains(text, '0.40.0');
assertStringContains(text, '🦕');
},
});

// TODO(lucacasonato): reenable test on macOS
if (Deno.build.os === 'linux') {
Deno.test({
name: 'run on now dev',
name: 'run on vercel dev',
async fn() {
const proc = Deno.run({
cmd: runNow.concat('dev', '-t', Deno.env.get('NOW_TOKEN')!),
cmd: runNow.concat('dev', '-t', Deno.env.get('VERCEL_TOKEN')!),
cwd: join(Deno.cwd(), 'example'),
stdout: 'inherit',
stderr: 'inherit',
Expand All @@ -80,8 +80,8 @@ if (Deno.build.os === 'linux') {
const req = await fetch(`http://localhost:3000/api/version`);
if (req.ok) {
const text = await req.text();
assertStrContains(text, 'Welcome to deno');
assertStrContains(text, '🦕');
assertStringContains(text, 'Welcome to deno');
assertStringContains(text, '🦕');
proc.kill(2);
proc.close();
Deno.exit(0);
Expand All @@ -93,7 +93,7 @@ if (Deno.build.os === 'linux') {
}
proc.kill(2);
proc.close();
throw Error('Failed to send request to now dev');
throw Error('Failed to send request to vercel dev');
},
});
}
12 changes: 6 additions & 6 deletions .github/workflows/update-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
readJson,
writeJson,
ensureDir,
} from 'https://deno.land/std@v0.42.0/fs/mod.ts';
} from 'https://deno.land/std@0.68.0/fs/mod.ts';
const sha = Deno.env.get('GITHUB_SHA');
if (!sha) {
throw Error('No GITHUB_SHA specified.');
Expand All @@ -17,11 +17,11 @@ pkg.name = name;
pkg.version = tag;
await writeJson('package.json', pkg, { spaces: 2 });

const now: any = await readJson('example/now.json');
now.functions['api/**/*.ts'].runtime = `${name}@${tag}`;
await writeJson('example/now.json', now, { spaces: 2 });
await ensureDir('example/.now');
await writeJson('example/.now/project.json', {
const vercel: any = await readJson('example/vercel.json');
vercel.functions['api/**/*.ts'].runtime = `${name}@${tag}`;
await writeJson('example/vercel.json', vercel, { spaces: 2 });
await ensureDir('example/.vercel');
await writeJson('example/.vercel/project.json', {
projectId: 'QmT3dw3FcMmKeRh24bRCTR6iF5VCp6kB5CNjgGePK57cC6',
orgId: 'eTmgUytG3YzmHs86JcUzFSmc',
});
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dist
node_modules
.now
.vercel
.vscode
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This builder allows you to run [Deno](https://deno.land) as a lambda on `vercel`
If you're unfamiliar with `vercel` runtimes, please read the [runtime docs](https://vercel.com/docs/runtimes) first. This runtime can be used like any other Community Runtime.

```json
// now.json
// vercel.json
{
"functions": {
"api/**/*.{j,t}s": {
Expand Down Expand Up @@ -49,10 +49,10 @@ That's the simplest way to use this runtime!

### Specific Deno version

To use a specific version of Deno you can specify a environment variable in your `now.json`:
To use a specific version of Deno you can specify a environment variable in your `vercel.json`:

```json
// now.json
// vercel.json
{
"functions": {
...
Expand All @@ -65,10 +65,10 @@ To use a specific version of Deno you can specify a environment variable in your

### Unstable mode

To use Deno's `unstable` mode you can specify the environment variable `DENO_UNSTABLE` in your `now.json`:
To use Deno's `unstable` mode you can specify the environment variable `DENO_UNSTABLE` in your `vercel.json`:

```json
// now.json
// vercel.json
{
"functions": {
...
Expand Down
2 changes: 1 addition & 1 deletion example/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.now
.vercel
2 changes: 1 addition & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Zeit Now Deno</title>
<title>Vercel Deno</title>
</head>
<body>
<div id="content">contacting api...</div>
Expand Down
File renamed without changes.
22 changes: 10 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,29 @@
"dev": "tsc --watch",
"build": "tsc",
"prepublishOnly": "tsc",
"test": "tsc && jest",
"typecheck": "tsc --noEmit"
},
"files": [
"dist"
],
"dependencies": {
"@now/build-utils": "^0.9.6",
"@types/command-exists": "^1.2.0",
"@types/which": "^1.3.2",
"acorn": "^6.4.1",
"command-exists": "^1.2.8",
"execa": "^1.0.0",
"fs-extra": "^7.0.1",
"now": "^18.0.0",
"@vercel/build-utils": "^2.5.1",
"acorn": "^8.0.1",
"command-exists": "^1.2.9",
"execa": "^4.0.3",
"fs-extra": "^9.0.1",
"vercel": "^20.1.0",
"which": "^2.0.2"
},
"devDependencies": {
"@types/execa": "^0.9.0",
"@types/fs-extra": "^7.0.0",
"jest": "^24.8.0",
"@types/execa": "^2.0.0",
"@types/fs-extra": "^9.0.1",
"ms": "^2.1.2",
"node-fetch": "^2.6.0",
"prettier": "^1.18.2",
"typescript": "3.5.2"
"prettier": "^2.1.1",
"typescript": "^4.0.2"
},
"prettier": {
"useTabs": false,
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
DownloadedFiles,
Files,
debug,
} from '@now/build-utils';
} from '@vercel/build-utils';
import {
ensureDeno,
replaceBinDeno,
Expand Down Expand Up @@ -81,6 +81,7 @@ async function buildDenoLambda(

debug('building single file');
const entrypointPath = downloadedFiles[entrypoint].fsPath;
console.log(entrypointPath);
const entrypointDirname = path.dirname(entrypointPath);

const extname = path.extname(entrypointPath);
Expand Down
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path';

export const getWorkPath = (workPath: string, entrypoint: string) =>
path.join(workPath, '.now', 'builders', 'now-deno', entrypoint);
path.join(workPath, '.vercel', 'builders', 'now-deno', entrypoint);
Loading