Skip to content

Commit

Permalink
chore: improve the way lockfiles are handled
Browse files Browse the repository at this point in the history
  • Loading branch information
lowlighter committed Dec 16, 2024
1 parent f48866e commit 0f6d873
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
13 changes: 1 addition & 12 deletions .github/tools/github_actions_deno_deploy.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
// deno-lint-ignore-file no-explicit-any
// Imports
import * as JSONC from "@std/jsonc"
import * as core from "@actions/core"

// Ensure script is run in CI environment
if (!Deno.env.get("CI")) {
throw new Error("This script should be run only in CI environment")
}

// Remove lockfiles and package.json to avoid resolution conflicts
// https://github.com/denoland/deno/issues/27380
await Deno.remove("deno.lock", { recursive: true })
await Deno.remove("package.json", { recursive: true })
await Deno.remove("package-lock.json", { recursive: true })

// Parse deno.jsonc and print deno deploy flags
// deno-lint-ignore no-explicit-any
const config = JSONC.parse(await Deno.readTextFile("./deno.jsonc")) as any
await Deno.writeTextFile(".imports.json", JSON.stringify({ imports: config.imports }, null, 2))
core.setOutput("project", config.deploy.project)
Expand Down
8 changes: 6 additions & 2 deletions deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
"command": "cd $INIT_CWD && bun test"
},
// Building tasks
"build:lockfile": {
"description": "Build deno.lock and package-lock.json",
"command": "rm -rf deno.lock package.json package-lock.json && deno install && git checkout package.json && npm install"
},
"build:www": {
"description": "Build website",
"command": "deno run --quiet --allow-read --allow-env --allow-net --allow-sys=osRelease --allow-write=www/.pages --allow-run=$(deno task resolve:glob \"$DENO_DIR/**/@esbuild/**/esbuild\") --location=http://localhost:4649 www/build.ts",
Expand All @@ -68,13 +72,13 @@
// Continuous integration tasks
"ci:setup-deno-deploy": {
"description": "Setup deno deploy environment",
"command": "deno run --allow-read --allow-env --allow-write=.imports.json,deno.lock,package.json,package-lock.json,/home/runner/work/_temp .github/tools/github_actions_deno_deploy.ts",
"command": "deno task build:lockfile && rm -rf package.json package-lock.json && deno run --allow-read --allow-env --allow-write=.imports.json,/home/runner/work/_temp .github/tools/github_actions_deno_deploy.ts",
"dependencies": ["build:www", "build:coverage", "render:mermaid"]
},
"ci:autogenerate": {
"description": "Autogenerate files",
"command": "sleep 0",
"dependencies": ["repo:fill-scopes", "render:mermaid", "render:readmes"]
"dependencies": ["build:lockfile", "repo:fill-scopes", "render:mermaid", "render:readmes"]
},
// Development tasks
"qa": {
Expand Down

0 comments on commit 0f6d873

Please sign in to comment.