Coder Social home page Coder Social logo

deployctl's Introduction

deployctl

deployctl is the command line tool for Deno Deploy. This repository also contains the denoland/deployctl GitHub Action.

Prerequisite

You need to have Deno 1.41.1+ installed (latest version is recommended; just run deno upgrade)

Install

deno install -Arf jsr:@deno/deployctl

Usage

The easiest way to get started with deployctl is to deploy one of the examples in the examples directory:

cd examples/hello-world
deployctl deploy

Visit the deployctl docs and check out the help output to learn all you can do with deployctl:

deployctl -h

Action Example

name: Deploy

on: push

jobs:
  deploy:
    runs-on: ubuntu-latest

    permissions:
      id-token: write # This is required to allow the GitHub Action to authenticate with Deno Deploy.
      contents: read

    steps:
      - name: Clone repository
        uses: actions/checkout@v3

      - name: Deploy to Deno Deploy
        uses: denoland/deployctl@v1
        with:
          project: my-project # the name of the project on Deno Deploy
          entrypoint: main.ts # the entrypoint to deploy

To learn more about the action, checkout action readme.

deployctl's People

Contributors

alexisbouchez avatar alexxnica avatar arnauorriols avatar ayoreis avatar ericlery avatar furiouzz avatar kt3k avatar lino-levan avatar lowlighter avatar lucab avatar lucacasonato avatar magurotuna avatar osdiab avatar piscisaureus avatar ribizli avatar rojvv avatar rolitoxdd avatar ry avatar satyarohith avatar uki00a avatar ultirequiem avatar wesleycoder avatar willnewby avatar wperron avatar xdrdak avatar yeskunall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deployctl's Issues

Outdated types

According to the docs, Deno.readFile is available but when I inspect the deployctl.d.ts file, there's no declaration of it at all

Add "New version available" message

When starting the check or run subcommand of the CLI, we should fetch the latest version in the background. When the user exits the application (on "close" event), we should print out a message if there is a newer version available, like gh CLI does. It should look something like this:

> deno check main.ts
OK

A new release of deployctl is available: 0.2.0 -> 0.3.0
To upgrade, run `deployctl upgrade`
https://github.com/denoland/deployctl/releases/tag/0.3.0

This should only happen if stdin is a tty (Deno.isatty(Deno.stdin.rid) returns true).

Better usability when type checking

import { h, jsx, serve} from "https://deno.land/x/[email protected]/mod.ts";

const App = () => (
  <div>
    <h1>Hello Work!</h1>
  </div>
);

const NotFound = () => (
  <div>
    <h1>Page not found</h1>
  </div>
);

serve({
  "/": () => jsx(<App />),
  404: () => jsx(<NotFound />, { status: 404 }),
});
# deployctl run index.tsx
Check file:///Users/ry/src/deploy-website/$deno$eval.ts
error: TS6200 [ERROR]: Definitions of the following identifiers conflict with those in another file: DOMException, Event, EventTarget, EventListenerOrEventListenerObject, ProgressEvent, TextDecoder, TextEncoder, AbortController, URLSearchParams, URL, ReadableStreamReader, CountQueuingStrategy, ByteLengthQueuingStrategy, BlobPart, Blob, File, FormDataEntryValue, FormData, HeadersInit, Headers, RequestInfo, RequestCache, RequestCredentials, RequestMode, RequestRedirect, ReferrerPolicy, BodyInit, RequestDestination, Request, ResponseType, Response, CloseEvent, WebSocket, BinaryType, CompileError, Global, Instance, LinkError, Memory, Module, RuntimeError, Table, ImportExportKind, TableKind, ValueType, ExportValue, Exports, ImportValue, ModuleImports, Imports, BufferSource, MessageEvent, ErrorEvent, CustomEvent, Window
interface Account {
~~~~~~~~~
    at asset:///lib.dom.d.ts:25:1

    Conflicts are in this file.
    declare class DOMException extends Error {
    ~~~~~~~
        at file:///Users/ry/Library/Caches/deno/https/deno.land/a54873ce745491942abde8874b5ea92f343a9be4a5413e78dfe7c94fcfe2b201.ts:11:1

however works with

 deployctl run --libs=ns,fetchevent  index.tsx

deployment fails with `--no-static` flag

➜ deployctl deploy --project=testhello ./hello.jsx --no-static
✔ Project: testhello
error: The deployment failed: module with specifier 'file:///src/hello.jsx' not found

Crashes with JSON `SyntaxError` when source has its own syntax error

For example:

> cat repro.ts 
function asdf extends Error {}

> deployctl run repro.ts
error: Expected (, got extends at file:///tmp/repro.ts:1:14
error: Uncaught (in promise) SyntaxError: Unexpected end of JSON input
    JSON.parse(new TextDecoder().decode(raw)).modules;
         ^
    at JSON.parse (<anonymous>)
    at analyzeDeps (https://deno.land/x/[email protected]/src/utils/info.ts:24:10)
    at async once (https://deno.land/x/[email protected]/src/subcommands/run.ts:97:17)
    at async default (https://deno.land/x/[email protected]/src/subcommands/run.ts:90:21)
    at async https://deno.land/x/[email protected]/deployctl.ts:61:13

Like with #34, this crash causes deployctl to exit completely when running with --watch instead of waiting for a file change to try again.

Version flag alias is capitalized

I'm not sure this is an issue or it's meant to be like this, but the alias for --version flag is a capital -V instead of -v which seems like a typo.

I can submit a PR to fix it in case it's indeed a typo.

deploying statically generated site

would be cool if we could allow github action yaml file to look like this:

- uses: denoland/deployctl@v1
        with:
          project: example-deno-eleventy
          static: _site

instead of:

- uses: denoland/deployctl@v1
        with:
          project: example-deno-eleventy
          entrypoint: https://deno.land/[email protected]/http/file_server.ts
          root: _site

quotes.ts example is failing to run

I'm trying to run quotes.ts from https://deno.com/deploy/docs/tutorial-faunadb but it'll give me error messages below.

I'm not sure how to resolve the conflict error:

→ deployctl run ./quotes.ts
Check file:///Users/marcosvm/code/deno/quotes/$deno$eval.ts
error: TS6200 [ERROR]: Definitions of the following identifiers conflict with those in another file: DOMException, Event, EventTarget, EventListenerOrEventListenerObject, ProgressEvent, TextDecoder, TextEncoder, AbortController, URLSearchParams, URL, ReadableStreamReader, CountQueuingStrategy, ByteLengthQueuingStrategy, BlobPart, Blob, File, FormDataEntryValue, FormData, HeadersInit, Headers, RequestInfo, RequestCache, RequestCredentials, RequestMode, RequestRedirect, ReferrerPolicy, BodyInit, RequestDestination, Request, ResponseType, Response, CloseEvent, WebSocket, BinaryType, CompileError, Global, Instance, LinkError, Memory, Module, RuntimeError, Table, ImportExportKind, TableKind, ValueType, ExportValue, Exports, ImportValue, ModuleImports, Imports, BufferSource, MessageEvent, ErrorEvent, CustomEvent, Window
interface Account {
~~~~~~~~~
    at asset:///lib.dom.d.ts:25:1

    Conflicts are in this file.
    declare class DOMException extends Error {
    ~~~~~~~
        at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:11:1

TS2430 [ERROR]: Interface 'ReadableStreamDefaultReader<R>' incorrectly extends interface 'ReadableStreamGenericReader'.
  Types of property 'closed' are incompatible.
    Type 'Promise<void>' is not assignable to type 'Promise<undefined>'.
      Type 'void' is not assignable to type 'undefined'.
interface ReadableStreamDefaultReader<R = any> extends ReadableStreamGenericReader {
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at asset:///lib.dom.d.ts:12597:11

TS2345 [ERROR]: Argument of type 'unknown' is not assignable to parameter of type 'VNode<{}>'.
  return new Response(render(jsx), {
                             ~~~
    at https://deno.land/x/[email protected]/util.ts:22:30

TS2339 [ERROR]: Property 'keys' does not exist on type 'URLSearchParams'.
    for (const param of searchParams.keys()) {
                                     ~~~~
    at https://deno.land/x/[email protected]/util.ts:72:38

TS2339 [ERROR]: Property 'keys' does not exist on type 'Headers'.
    for (const header of request.headers.keys()) {
                                         ~~~~
    at https://deno.land/x/[email protected]/util.ts:95:42

TS2304 [ERROR]: Cannot find name 'body'.
    const { quote, author } = body;
                              ~~~~
    at file:///Users/marcosvm/code/deno/quotes/quotes.ts:36:31

TS6200 [ERROR]: Definitions of the following identifiers conflict with those in another file: DOMException, Event, EventTarget, EventListenerOrEventListenerObject, ProgressEvent, TextDecoder, TextEncoder, AbortController, URLSearchParams, URL, ReadableStreamReader, CountQueuingStrategy, ByteLengthQueuingStrategy, BlobPart, Blob, File, FormDataEntryValue, FormData, HeadersInit, Headers, RequestInfo, RequestCache, RequestCredentials, RequestMode, RequestRedirect, ReferrerPolicy, BodyInit, RequestDestination, Request, ResponseType, Response, CloseEvent, WebSocket, BinaryType, CompileError, Global, Instance, LinkError, Memory, Module, RuntimeError, Table, ImportExportKind, TableKind, ValueType, ExportValue, Exports, ImportValue, ModuleImports, Imports, BufferSource, MessageEvent, ErrorEvent, CustomEvent, Window
declare class DOMException extends Error {
~~~~~~~
    at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:11:1

    Conflicts are in this file.
    interface Account {
    ~~~~~~~~~
        at asset:///lib.dom.d.ts:25:1

TS2403 [ERROR]: Subsequent variable declarations must have the same type.  Variable 'ReadableStreamDefaultReader' must be of type '{ new <R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>; prototype: ReadableStreamDefaultReader<any>; }', but here has type '{ new <R>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>; prototype: ReadableStreamDefaultReader<any>; }'.
declare var ReadableStreamDefaultReader: {
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:521:13

    'ReadableStreamDefaultReader' was also declared here.
    declare var ReadableStreamDefaultReader: {
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~
        at asset:///lib.dom.d.ts:12602:13

TS2314 [ERROR]: Generic type 'ReadableStreamReader' requires 1 type argument(s).
  prototype: ReadableStreamReader;
             ~~~~~~~~~~~~~~~~~~~~
    at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:533:14

TS2314 [ERROR]: Generic type 'ReadableStreamReader' requires 1 type argument(s).
  new (): ReadableStreamReader;
          ~~~~~~~~~~~~~~~~~~~~
    at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:534:11

TS2403 [ERROR]: Subsequent variable declarations must have the same type.  Variable 'ReadableStream' must be of type '{ new <R = any>(underlyingSource?: UnderlyingSource<R> | undefined, strategy?: QueuingStrategy<R> | undefined): ReadableStream<R>; prototype: ReadableStream<...>; }', but here has type '{ new (underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number | undefined; size?: undefined; } | undefined): ReadableStream<Uint8Array>; new <R = any>(underlyingSource?: UnderlyingSource<...> | undefined, strategy?: QueuingStrategy<...> | undefined): ReadableStream<...>; prototype: ReadableStrea...'.
declare var ReadableStream: {
            ~~~~~~~~~~~~~~
    at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:658:13

    'ReadableStream' was also declared here.
    declare var ReadableStream: {
                ~~~~~~~~~~~~~~
        at asset:///lib.dom.d.ts:12580:13

TS2717 [ERROR]: Subsequent property declarations must have the same type.  Property 'closed' must be of type 'Promise<undefined>', but here has type 'Promise<void>'.
  readonly closed: Promise<void>;
           ~~~~~~
    at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:719:12

    'closed' was also declared here.
        readonly closed: Promise<undefined>;
                 ~~~~~~
        at asset:///lib.dom.d.ts:18811:14

TS2717 [ERROR]: Subsequent property declarations must have the same type.  Property 'ready' must be of type 'Promise<undefined>', but here has type 'Promise<void>'.
  readonly ready: Promise<void>;
           ~~~~~
    at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:721:12

    'ready' was also declared here.
        readonly ready: Promise<undefined>;
                 ~~~~~
        at asset:///lib.dom.d.ts:18813:14

TS2403 [ERROR]: Subsequent variable declarations must have the same type.  Variable 'WritableStreamDefaultWriter' must be of type '{ new <W = any>(stream: WritableStream<W>): WritableStreamDefaultWriter<W>; prototype: WritableStreamDefaultWriter<any>; }', but here has type '{ new (): WritableStreamDefaultWriter<any>; prototype: WritableStreamDefaultWriter<any>; }'.
declare var WritableStreamDefaultWriter: {
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:728:13

    'WritableStreamDefaultWriter' was also declared here.
    declare var WritableStreamDefaultWriter: {
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~
        at asset:///lib.dom.d.ts:18820:13

TS2375 [ERROR]: Duplicate number index signature.
  [index: number]: string;
  ~~~~~~~~~~~~~~~~~~~~~~~~
    at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:1653:3

TS2717 [ERROR]: Subsequent property declarations must have the same type.  Property 'subtle' must be of type 'SubtleCrypto', but here has type 'null'.
  readonly subtle: null;
           ~~~~~~
    at file:///Users/marcosvm/Library/Caches/deno/https/deno.land/10dacc910db04e7ca67ef115b78ef6a413eff3504212fadcf8546401fbfc1e0d.ts:1749:12

    'subtle' was also declared here.
        readonly subtle: SubtleCrypto;
                 ~~~~~~
        at asset:///lib.dom.d.ts:3749:14

Found 16 errors.
error: Process exited with code 1

I'm using:

→ deno -V
deno 1.8.2

with deployctl installed from:

 deno install --allow-read --allow-write --allow-env --allow-net --allow-run --no-check -f https://deno.land/x/deploy/deployctl.ts

Thank you for your help.

Bug: await request.formData() causes permanently pending responses

Problem:
await request.formData() causes responses to stay pending in Safari and Firefox (and when a redirect is involved, also in Chrome)

Steps to reproduce:

  1. Copy the code below into a .ts file and run it, e.g. deployctl run bug.ts
  2. Visit http://localhost:8080
  3. Submit the form
  4. Go back in your browser
  5. Submit the form again

Expected result:
The browser receives a response after form submission.

Actual result:
The browser does not receive a response.

Code:

// bug.ts

const form = `
  <form action="" method="post">
    <input name="text" type="text" value="Lorem ipsum" />
    <button>Submit</button>
  </form>
`;

addEventListener("fetch", (event: FetchEvent) => {
  event.respondWith(handleRequest(event.request));
});

async function handleRequest(request: Request): Promise<Response> {
  if (request.method === "POST") {
    const formData = await request.formData();
    console.log(formData.get("text"));

    return new Response("Go back and try a second time!", {
      headers: { "Content-Type": "text/plain" },
      status: 200,
    });

    // Uncomment below (and comment out above) to cause a pending response in all browsers on every form submission
    // return new Response(undefined, {
    //   headers: { Location: "/" },
    //   status: 303,
    // });
  }

  return new Response(form, {
    headers: { "Content-Type": "text/html" },
    status: 200,
  });
}

Observations:

  • The problem does not occur when there is no <input> element in the form
  • After two form submissions, there is only one log entry, i.e. the hang occurs before the log statement in the code.
  • When the hanging response is canceled by the user in the browser, the form can be submitted again with success. Going back and submitting a fourth time causes a new hang.
  • When a redirect is tried after parsing the form, the issue is even more pronounced (causes hang in all browsers each time the form is submitted)

Environment:
Firefox 88.0.1 (64-bit)
Safari 14.1 (15611.1.21.161.7, 15611)
Chrome 90.0.4430.212

deno 1.10.2 (release, x86_64-apple-darwin)
v8 9.1.269.27
typescript 4.2.2

captureStackTrace does not exist on type ErrorConstructor

deployctl produces typescript compilation errors when the Error.captureStackTrace is used along with --libs=ns,fetchevent (see this for why I am doing this).

deployctl run --libs=ns,fetchevent src/mod.ts
Check file:///Users/kyeotic/dev/brophylactic-bot/$deno$eval.ts
error: TS2339 [ERROR]: Property 'captureStackTrace' does not exist on type 'ErrorConstructor'.
  Error.captureStackTrace(errorStack);
        ~~~~~~~~~~~~~~~~~
    at https://raw.githubusercontent.com/discordeno/discordeno/12.0.1/src/rest/run_method.ts:36:9
error: Process exited with code 1

This is related to this deno issue. If its possible to fix this error by including another lib that would solve the issue for me.

Running `deployctl` using --unstable

Hey! I'm trying out Deno Deploy and wanted to connect to a MySQL database, when I important and construct the Client class from the mysql third-party package. I get notifified that certain properties don't exists on the Deno instance and that I might want to use the --unstable flag.

So I figured same old, same old and added --unstable but this threw an error. After I checked out the help text I noticed that there isn't an option for the unstable flag, Does this mean that it's impossible to run packages that require --unstable using Deno Deploy? I figure this will cross of alot of packages from being compatible with the hosting service

'readFileSync' does not exist on type 'typeof Deno'.

Hey!

Sorry for the shallow post, I'm rather new in the world of Deno.

I've been utilizing deployctl to develop an API service that uses dotenv for storing secret tokens.

Every time i import the library and run deployctl run --libs=ns,fetchevent ./index.ts I get the following error:

Check file:///Users/user/sites/vilbergs/repo/$deno$eval.ts
error: TS2339 [ERROR]: Property 'readFileSync' does not exist on type 'typeof Deno'.
    return parse(new TextDecoder("utf-8").decode(Deno.readFileSync(filepath)));
                                                      ~~~~~~~~~~~~
    at https://deno.land/x/[email protected]/mod.ts:76:55

TS2339 [ERROR]: Property 'errors' does not exist on type 'typeof Deno'.
    if (e instanceof Deno.errors.NotFound) return {};
                          ~~~~~~
    at https://deno.land/x/[email protected]/mod.ts:78:27

Here is the source repo. The examples above are slightly altered from the source to keep things agnostic to the purpose of my api.

Add timers APIs

Timers have been enabled in Deploy 🎉 we can enable these APIs in deployctl as well

Deno.readDir and Deni.cwd not available when deployed

Hi, I am creating a simple blog using pagic and oak with Deno. I can run my code fine locally using deployctl but I get these errors when the code is deployed.

[uncaught oak error]: TypeError - Deno.cwd is not a function

[uncaught oak error]: TypeError - Deno.readDir(...) is not a function or its return value is not async iterable

My code looks as follows:


const app = new Application();
const router = new Router();

router.get("/", async (ctx) => {
  let links = [];
  for await (const dirEntry of Deno.readDir("public")) {
    if (dirEntry.isFile && dirEntry.name.match("^[a-zA-Z]+.[a-zA-Z]+.html$")) {
      console.log(dirEntry);
      links.push(`<a href="${dirEntry.name}">${dirEntry.name}</a>`);
    }
  }

  ctx.response.headers.set("Content-Type", "html");
  ctx.response.body = `
    <h1>Blog</h1>
    <h5>Example blog using Deno</h5>
    <p>Posts:</p>
    ${links}
  `;
});

app.use(router.routes());

// Send static content
app.use(async (context) => {
  await context.send({
    root: `${Deno.cwd()}/public`,
  });
});

addEventListener("fetch", app.fetchEventHandler());

Any help is appreciated.

Every second request hangs with simple proxy worker example

i encounter a weird bug in deployctl (i tested using deno 1.9.2 and 1.9.1 and deployctl 0.3.0 on apple M1 and on intel build)
when i run a simple worker like this:
deployctl run --reload --no-check --addr=:8086 script.js

script.js :

self.addEventListener("fetch", (event) => {
  event.respondWith(fetch('http://google.com'))
});

every second request to the endpoint hangs and only when i cancel the request client side, then the next request works again and so on.
this only happens if i do the requests from chrome or insomnia, but not with curl as cli, which might point to an issue with connection reuse, i inspected the headers that chrome and insomnia use vs the curl cli ones but could not find a suspicious difference.

the bug could also be reproduced with a different local webserver.

the same behaviour is shown if i use https://deno.land/x/[email protected]/listen.ts with the same worker code, which is a completely different implementation but also uses Deno.serveHttp, so this might point to a bug in deno.

possible connection to: deno issue #10182

`deployctl run` shouldn't type check `.js` files

Reproduction:

import { json, serve } from "https://deno.land/x/[email protected]/mod.ts";

serve({
  "/": () => json({ message: "hello world" }),
  "api/create": () => json({ message: "created" }, { status: 201 }),
});

Save it as hello.js and run deployctl run hello.js. It will show some type conflicts.

error: TS6200 [ERROR]: Definitions of the following identifiers conflict with those in another file: DOMException, Event, EventTarget, EventListenerOrEventListenerObject, ProgressEvent, TextDecoder, TextEncoder, AbortController, URLSearchParams, URL, ReadableStreamReader, CountQueuingStrategy, ByteLengthQueuingStrategy, BlobPart, Blob, File, FormDataEntryValue, FormData, HeadersInit, Headers, RequestInfo, RequestCache, RequestCredentials, RequestMode, RequestRedirect, ReferrerPolicy, BodyInit, RequestDestination, Request, ResponseType, Response, CloseEvent, WebSocket, BinaryType, CompileError, Global, Instance, LinkError, Memory, Module, RuntimeError, Table, ImportExportKind, TableKind, ValueType, ExportValue, Exports, ImportValue, ModuleImports, Imports, BufferSource, MessageEvent, ErrorEvent, CustomEvent, Window

Ref satyarohith/sift#18

Set Deno.noColor attr to false

I maintain a logging library and like most logging libraries (including std/log) it imports various colors from /std/fmt/colors.ts. My library is built to not use colors when they are not available, via Deno.noColor.

However, when I import my library into a deno deploy script, I get this error when running deployctl check on it:

error: TS2339 [ERROR]: Property 'noColor' does not exist on type 'typeof Deno'.
const noColor = globalThis.Deno?.noColor ?? true;
                                 ~~~~~~~
    at https://deno.land/[email protected]/fmt/colors.ts:15:34

Simple reproduction by running deployctl check mod.ts with mod.ts as follows:

import { blue } from "https://deno.land/[email protected]/fmt/colors.ts";

addEventListener("fetch", (event) => {
    const response = new Response("Hello World!", {
      headers: { "content-type": "text/plain" },
    });
    event.respondWith(response);
  });

A simple fix would be to set Deno.noColor = false I believe.

APIError: GitHub event 'schedule' is not supported.

Hello while building my project in GitHub actions for a custom build process I ran in to a problem with deployctl failing if the deployment was trigger on a schedule in GitHub actions
Screenshot 2022-04-08 at 11 13 28

the CD.yaml I use

name: Continuous Deployment

on:
    push:
        branches:
            - main
    pull_request:
        branches:
            - main
    schedule:
        # every hour
        - cron: '0 * * * *'
    workflow_dispatch:

jobs:
    ci:
        runs-on: ${{ matrix.os }}
        permissions:
            id-token: write
            contents: read

        strategy:
            matrix:
                os: [ubuntu-latest]
                deno-version: [1.20.4]

        steps:
            - name: Git Checkout Deno Module
              uses: actions/checkout@v2

            - name: Use Deno Version ${{ matrix.deno-version }}
              uses: denolib/setup-deno@v2
              with:
                  deno-version: ${{ matrix.deno-version }}

            - name: Run build 👷
              run: make build

            - name: Upload to Deno Deploy
              uses: denoland/deployctl@v1
              with:
                  project: '******'
                  entrypoint: './main.ts'

Looking at the code why this would happen I didn't came any closer then /deployctl/blob/main/action/index.js where you start defining the the switch case for the event types. Either the event type has an extra step which is not defined or the API it self gets an type it's confused about.

Here is a build that was triggered on a push that did succeed
Screenshot 2022-04-08 at 11 24 17

Deno.test Not Recognized

Given a module internally calls Deno.test
When deployctl runs a JSX that imports that module
Then the following error is shown:

error: TS2339 [ERROR]: Property 'test' does not exist on type 'typeof Deno'.
      return Deno.test(testName, () => assert(assertion.evaluate()));

Deploy error on Dash

Hi all,

Since I'm not sure where to report this issue, I'll try here.

When I try to link my public github repo, I'm getting following error:

The GitHub repository you are requesting was not found, or you do not have access to view it.

And the screenshot:

image

I created public repo with such code:

addEventListener("fetch", (event) => {

  const resp = new Response("Hello", {
    headers: { "content-type": "text/plain" },
  });

  event.respondWith(resp);
});

deployctl works well though, but if I want to push to Github deployment is not linked, so I need to manually trigger deployment on dash.deno.com using "Depoy URL" button.

Am I missing something stupid? Or there's a bug right there 🤔

Thank you!
Marko

Watcher throws bland message when importing nonexistent module

When mod.ts imports nonexistent.ts:

> deployctl run mod.ts --watch
error: Uncaught (in promise) NotFound: No such file or directory (os error 2)
    const watcher = Deno.watchFs(deps);
^
    at handleError (deno:core/core.js:186:12)
    at jsonOpParseResult (deno:core/core.js:356:9)
    at opSync (deno:core/core.js:259:32)
    at Object.jsonOpSync (deno:core/core.js:372:12)
    at new FsWatcher (deno:runtime/js/40_fs_events.js:13:24)
    at Object.watchFs (deno:runtime/js/40_fs_events.js:49:12)
    at watch (https://deno.land/x/[email protected]/src/subcommands/run.ts:108:1)
    at async default (https://deno.land/x/[email protected]/src/subcommands/run.ts:89:1)
    at async https://deno.land/x/[email protected]/deployctl.ts:61:1

Comparatively, deno cache shows the actual issue:

> deno cache mod.ts 
error: Cannot resolve module "file:///work/nonexistent.ts" from "file:///work/mod.ts".
    at file:///work/mod.ts:1:0

This is a trivial example, which can be less obvious when refactoring files in a larger project with the watcher running.

How to deploy SPA to deno.com?

I read that I can deploy SPA, but I see that API Reference has no Deno.open.
deployctl check mode.ts says the same, and deno.com as well for such code:

import { urlParse } from 'https://deno.land/x/url_parse/mod.ts';

addEventListener('fetch', (event: FetchEvent) => {
    event.respondWith(handleRequest(event.request));
});

async function handleRequest(request: Request) {
    const okFile = Deno.open(import.meta.url);

    const resultResponse = new Response(null, {
       headers: {
          body: okFile,
        },
    });

    return resultResponse;
}

Could you please tell me how can I serve static files, like style and images?

EDIT: Maybe related to #20.

Implement `deployctl upgrade`

Once this module is published to deno.land/x/deploy, this command should check if any newer versions of the tool are available, and automatically deno install it over the existing installation.

bug: local files are not intact when served

Steps to reproduce.

  1. Download an image.
curl https://raw.githubusercontent.com/nonstdout/deno-deploy/main/smiley.png > smiley.png
  1. Run this script.
addEventListener("fetch", (event) => {
  event.respondWith(fetch(new URL("./smiley.png", import.meta.url)));
});
  1. Download the image again from the local server.
curl localhost:8080 > new.png

Try to open the new.png, and you'll see it being corrupted.

Edit:
Versions: deployctl from main and deno 1.11.0

BadResource error when file changes in watch mode

Using example in https://deno.com/examples/hello.js or any script.
This error is produced by changing the file.

Check file:///mnt/d/code/tmdh-api/$deno$eval.ts
Check data:application/typescript;base64,aW1wb3J0IHR5cGUge30gZnJvbSAiZmlsZTovLy9ob21lL3RhcmVxdWUvLmNhY2hlL2Rlbm8vaHR0cHMvZGVuby5sYW5kLzM4OTc2MjU3OGRmMmE4YWUwYTZkMTg5NWQ1MWFmMTVjY2QxNzFiODEyMTNjYmVmNDQ4NGM0MTQ1MjJmYzE0MmYudHMiO2ltcG9ydCB0eXBlIHt9IGZyb20gImZpbGU6Ly8vaG9tZS90YXJlcXVlLy5jYWNoZS9kZW5vL2h0dHBzL2Rlbm8ubGFuZC9hNTQ4NzNjZTc0NTQ5MTk0MmFiZGU4ODc0YjVlYTkyZjM0M2E5YmU0YTU0MTNlNzhkZmU3Yzk0ZmNmZTJiMjAxLnRzIjtpbXBvcnQgdHlwZSB7fSBmcm9tICJmaWxlOi8vL2hvbWUvdGFyZXF1ZS8uY2FjaGUvZGVuby9odHRwcy9kZW5vLmxhbmQvNzQ2N2JjNzY2Mzg4MGI1MzM5ZjM2ZWUwYWQ2ZGNiY2QzNDljMmI5YzM5NmE0OGI0MDYxNjc5YzNiZWNkMTNiMi50cyI7aW1wb3J0ICJmaWxlOi8vL21udC9kL2NvZGUvdG1kaC1hcGkvaGVsbG8uanMiOw==
Listening on http://0.0.0.0:8080
/mnt/d/code/tmdh-api/hello.js changed. Restarting...
Check file:///mnt/d/code/tmdh-api/$deno$eval.ts
/mnt/d/code/tmdh-api/hello.js changed. Restarting...
error: Uncaught (in promise) BadResource: Bad resource ID
}
 ^
    at deno:core/01_core.js:106:46
    at unwrapOpResult (deno:core/01_core.js:126:13)
    at opSync (deno:core/01_core.js:140:12)
    at Object.close (deno:core/01_core.js:148:5)
    at FsWatcher.return (deno:runtime/js/40_fs_events.js:43:12)
    at https://deno.land/x/[email protected]/src/subcommands/run.ts:146:2

OS: Linux
Deno version:

deno 1.13.0 (release, x86_64-unknown-linux-gnu)
v8 9.3.345.11
typescript 4.3.5

`--help` output is sent to `stderr` and exits with code 1

➜  ~ deployctl --help 2> stderr
➜  ~ cat stderr
deployctl 0.0.1
Run Deno Deploy scripts locally.

To run a script locally:
  deployctl run https://deno.land/x/deploy/examples/hello.js

To run a script locally and watch changes:
  deployctl run --watch https://deno.land/x/deploy/examples/hello.js

SUBCOMMANDS:
    run       Run a script given a filename or url
    check     Perform type checking of the script without actually running it
    types     Print the Deno Deploy TypeScript declarations

Support serving local files

.
├── index.html
└── mod.ts

mod.ts:

addEventListener("fetch", (event) => {
  event.respondWith(fetch(new URL("index.html", import.meta.url)));
});
deployctl run --no-check mod.ts 

Getting the following error when running the above command.

Listening on http://0.0.0.0:8080
error: Uncaught (in promise) TypeError: scheme 'file' not supported
  event.respondWith(fetch(new URL("index.html", import.meta.url)));
^
    at handleError (deno:core/core.js:186:12)
    at jsonOpParseResult (deno:core/core.js:356:9)
    at opSync (deno:core/core.js:259:32)
    at Object.jsonOpSync (deno:core/core.js:372:12)
    at opFetch (deno:op_crates/fetch/26_fetch.js:887:17)
    at sendFetchReq (deno:op_crates/fetch/26_fetch.js:1257:44)
    at fetch (deno:op_crates/fetch/26_fetch.js:1379:31)
    at file:///Users/sr/c/github.com/denoworld/deno.world/dir/mod.ts:8:1
    at innerInvokeEventListeners (deno:op_crates/web/02_event.js:750:27)
    at invokeEventListeners (deno:op_crates/web/02_event.js:785:5)
error: Process exited with code 1

runtime: export functions to start and stop the server in Deno code

Writing automated tests will be easier when we can start and stop the deploy server in Deno code.

Example code:

import {
  startServer,
  stopServer,
} from "https://deno.land/x/deployctl/runtime.js";

Deno.test("body is hello world", async () => {
  startServer(8910);

  addEventListener("fetch", (event) => {
    event.respondWith(new Response("Hello world"));
  });

  const response = await fetch("http://localhost:8910");
  const body = await response.text();
  assertEquals(body, "Hello world");
  stopServer();
});

I'm not sure if this would be the best approach to test deploy code. Let me know your thoughts.

(cc @lucacasonato)

https://deno.com/deploy doesn't support Blob

When I run locally, everything is OK, but failed on https://deno.com/deploy

TypeError: Blob is not a constructor
    at html (https://raw.githubusercontent.com/oyzhen/oyzhen/517bc3a47b0245158fe573482fe2423876818960/libs/serve.ts:33:17)
    at https://raw.githubusercontent.com/oyzhen/oyzhen/517bc3a47b0245158fe573482fe2423876818960/main.ts:3:21
    at handleRequest (https://raw.githubusercontent.com/oyzhen/oyzhen/517bc3a47b0245158fe573482fe2423876818960/libs/serve.ts:85:20)
    at https://raw.githubusercontent.com/oyzhen/oyzhen/517bc3a47b0245158fe573482fe2423876818960/libs/serve.ts:97:27
    at innerInvokeEventListeners (deno:op_crates/web/02_event.js:750:27)
    at invokeEventListeners (deno:op_crates/web/02_event.js:785:5)
    at dispatch (deno:op_crates/web/02_event.js:660:11)
    at dispatchEvent (deno:op_crates/web/02_event.js:984:14)
    at receiveRequests (deno:js/99_main.js:94:18)

Repo: oyzhen/oyzhen
URL: https://raw.githubusercontent.com/oyzhen/oyzhen/8139bcf20564f8886dad95d8143e0b4b17094c38/main.ts

Serving local files broken with 1.9.1

Getting the below error.

error: Uncaught (in promise) TypeError: HEAD and GET requests may not have a body.
        this.#request = new Request(new URL(stdReq.url, `http://${host}`).toString(), {
                        ^
    at new Request (deno:op_crates/fetch/23_request.js:273:15)
    at new FetchEvent (https://deno.land/x/[email protected]/src/runtime.bundle.js:2551:25)
    at serve1 (https://deno.land/x/[email protected]/src/runtime.bundle.js:2612:30)
error: Process exited with code 1

Reproduction:

  1. Create a file named local.js and paste the below code
addEventListener("fetch", (event) => {
  event.respondWith(fetch(new URL("local.js", import.meta.url)));
});
  1. Run deployctl run local.js

Deploy command wants access to my photos

I executed from my home directory, my terminal asked for permission to my photos and I denied then this exception was thrown. I assume it's just trying to walk my whole system from the current working directory. The command takes awhile before it even gets to this.

cotyhamilton ~
➜ deployctl deploy --project=clever-dog-43 dev/deno-example/wordle/api/mod.ts
✔ Project: clever-dog-43
⠧ Finding static assets...
error: Uncaught (in promise) PermissionDenied: Operation not permitted (os error 1), readdir '/Users/cotyhamilton/Pictures/Photos Library.photoslibrary'
  for await (const file of Deno.readDir(dir)) {
                   ^
    at async Object.[Symbol.asyncIterator] (deno:runtime/js/30_fs.js:125:16)
    at async walk (https://deno.land/x/[email protected]/src/utils/walk.ts:41:20)
    at async walk (https://deno.land/x/[email protected]/src/utils/walk.ts:67:18)
    at async walk (https://deno.land/x/[email protected]/src/utils/walk.ts:67:18)
    at async deploy (https://deno.land/x/[email protected]/src/subcommands/deploy.ts:153:21)
    at async default (https://deno.land/x/[email protected]/src/subcommands/deploy.ts:101:3)
    at async https://deno.land/x/[email protected]/deployctl.ts:101:5

It's unfortunate because the install command in the README grants the tool a lot of access.

Http: invalid HTTP method parsed

  1. Run script deployctl run --watch ./main.js
  2. Enter https://proxyhost.com/test.js link to the browser.
  3. An error is reported in terminal.

PS: Enter https://proxyhost.com link to the browser. There is no problem.

main.js

addEventListener("fetch", async (event) => {
  const { pathname } = new URL(event.request.url);
  if (pathname.startsWith("/test.js")) {
    const file = await Deno.readFile("./test.js");
    return new Response(file, {
      headers: {
        "content-type": "application/x-javascript",
      },
    });
  }
  const response = new Response("Hello World!", {
    headers: { "content-type": "text/plain" },
  });
  event.respondWith(response);
});

terminal info

Listening on http://0.0.0.0:8080
Http: invalid HTTP method parsed
    at deno:core/01_core.js:106:46
    at unwrapOpResult (deno:core/01_core.js:126:13)
    at async HttpConn.nextRequest (deno:ext/http/01_http.js:64:23)
    at async Object.next (deno:ext/http/01_http.js:137:26)
    at async handleConn (https://deno.land/x/[email protected]/src/runtime.bundle.js:1425:71)

deployctl version: 0.4.0

Deno version

deno 1.13.2 (release, x86_64-pc-windows-msvc)
v8 9.3.345.11
typescript 4.3.5

command error

I have run install command, but there is an error:

image

I haven't found any answer through Google for that error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.