Skip to content

refactor: remove --static flag #325

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 0 additions & 2 deletions src/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export function parseArgs(args: string[]) {
"help",
"prod",
"last",
"static",
"version",
"dry-run",
"save-config",
Expand Down Expand Up @@ -59,7 +58,6 @@ export function parseArgs(args: string[]) {
"env-file",
],
default: {
static: true,
config: Deno.env.get("DEPLOYCTL_CONFIG_FILE"),
token: Deno.env.get("DENO_DEPLOY_TOKEN"),
org: Deno.env.get("DEPLOYCTL_ORGANIZATION"),
Expand Down
72 changes: 31 additions & 41 deletions src/subcommands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { wait } from "../utils/spinner.ts";
import configFile from "../config_file.ts";
import { error } from "../error.ts";
import { API, APIError, endpoint } from "../utils/api.ts";
import type { ManifestEntry } from "../utils/api_types.ts";
import { parseEntrypoint } from "../utils/entrypoint.ts";
import { convertPatternToRegExp, walk } from "../utils/walk.ts";
import TokenProvisioner from "../utils/access_token.ts";
Expand Down Expand Up @@ -88,7 +87,6 @@ OPTIONS:

export interface Args {
help: boolean;
static: boolean;
prod: boolean;
exclude: string[];
include: string[];
Expand All @@ -108,7 +106,6 @@ export default async function (rawArgs: RawArgs): Promise<void> {
: null;
const args: Args = {
help: !!rawArgs.help,
static: !!rawArgs.static,
prod: !!rawArgs.prod,
token: rawArgs.token ? String(rawArgs.token) : null,
project: rawArgs.project ? String(rawArgs.project) : null,
Expand Down Expand Up @@ -150,7 +147,6 @@ export default async function (rawArgs: RawArgs): Promise<void> {
? null
: await parseEntrypoint(args.importMap, undefined, "import map")
.catch((e) => error(e)),
static: args.static,
prod: args.prod,
token: args.token,
project: args.project,
Expand All @@ -169,7 +165,6 @@ export default async function (rawArgs: RawArgs): Promise<void> {
interface DeployOpts {
entrypoint: string;
importMapUrl: URL | null;
static: boolean;
prod: boolean;
exclude: string[];
include: string[];
Expand Down Expand Up @@ -267,45 +262,40 @@ async function deploy(opts: DeployOpts): Promise<void> {
}

let uploadSpinner: Spinner | null = null;
const files = [];
let manifest: { entries: Record<string, ManifestEntry> } | undefined =
undefined;

if (opts.static) {
wait("").start().info(`Uploading all files from the current dir (${cwd})`);
const assetSpinner = wait("Finding static assets...").start();
const assets = new Map<string, string>();
const include = opts.include.map(convertPatternToRegExp);
const exclude = opts.exclude.map(convertPatternToRegExp);
const entries = await walk(cwd, cwd, assets, { include, exclude });
assetSpinner.succeed(
`Found ${assets.size} asset${assets.size === 1 ? "" : "s"}.`,
);

uploadSpinner = wait("Determining assets to upload...").start();
const neededHashes = await api.projectNegotiateAssets(project.id, {
entries,
});
wait("").start().info(`Uploading all files from the current dir (${cwd})`);
const assetSpinner = wait("Finding static assets...").start();
const assets = new Map<string, string>();
const include = opts.include.map(convertPatternToRegExp);
const exclude = opts.exclude.map(convertPatternToRegExp);
const entries = await walk(cwd, cwd, assets, { include, exclude });
assetSpinner.succeed(
`Found ${assets.size} asset${assets.size === 1 ? "" : "s"}.`,
);

uploadSpinner = wait("Determining assets to upload...").start();
const neededHashes = await api.projectNegotiateAssets(project.id, {
entries,
});

for (const hash of neededHashes) {
const path = assets.get(hash);
if (path === undefined) {
error(`Asset ${hash} not found.`);
}
const data = await Deno.readFile(path);
files.push(data);
}
if (files.length === 0) {
uploadSpinner.succeed("No new assets to upload.");
uploadSpinner = null;
} else {
uploadSpinner.text = `${files.length} new asset${
files.length === 1 ? "" : "s"
} to upload.`;
const files = [];
for (const hash of neededHashes) {
const path = assets.get(hash);
if (path === undefined) {
error(`Asset ${hash} not found.`);
}

manifest = { entries };
const data = await Deno.readFile(path);
files.push(data);
}
if (files.length === 0) {
uploadSpinner.succeed("No new assets to upload.");
uploadSpinner = null;
} else {
uploadSpinner.text = `${files.length} new asset${
files.length === 1 ? "" : "s"
} to upload.`;
}

const manifest = { entries };

if (opts.dryRun) {
uploadSpinner?.succeed(uploadSpinner?.text);
Expand Down
Loading