@shiplane/github-pages 0.6.0-nightly.14 → 0.6.0-nightly.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Ships a static site to GitHub Pages: fills
|
|
4
4
|
[shiplane](https://github.com/arnaud-zg/packages/blob/main/packages/shiplane/README.md)'s **static
|
|
5
|
-
hosting** port.
|
|
5
|
+
hosting** port. Each environment has its own folder on one branch, users' the rest, and none removes
|
|
6
|
+
another.
|
|
6
7
|
|
|
7
8
|
```mermaid
|
|
8
9
|
flowchart LR
|
|
@@ -10,7 +11,7 @@ flowchart LR
|
|
|
10
11
|
MOD --> GH["githubPagesStaticHosting()"]
|
|
11
12
|
GH --> BUILD["build with BASE_PATH"]
|
|
12
13
|
BUILD --> PRE["preview: /preview/"]
|
|
13
|
-
BUILD -->
|
|
14
|
+
BUILD --> PRODUCTION["production: the rest of the branch"]
|
|
14
15
|
```
|
|
15
16
|
|
|
16
17
|
## ⚡ Install
|
|
@@ -40,6 +41,7 @@ export default defineRelease({
|
|
|
40
41
|
ciPipeline: gitHubActionsCiPipeline(),
|
|
41
42
|
versioning: changesetsVersioning(),
|
|
42
43
|
}),
|
|
44
|
+
deployApps: { promote: [{ from: "preview", to: "production" }] },
|
|
43
45
|
modules: [webApp({ staticHosting: githubPagesStaticHosting() })],
|
|
44
46
|
});
|
|
45
47
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CatalogEntry, DeliveryAdapter, StaticHostingPort } from "shiplane/plugin";
|
|
2
2
|
|
|
3
3
|
//#region src/github-pages-static-hosting.adapter.d.ts
|
|
4
|
-
/** A static build on GitHub Pages:
|
|
4
|
+
/** A static build on GitHub Pages: each environment in its own folder, users' in the rest of the branch. */
|
|
5
5
|
type GithubPagesStaticHostingAdapter = DeliveryAdapter<StaticHostingPort>;
|
|
6
6
|
declare const githubPagesStaticHosting: () => GithubPagesStaticHostingAdapter;
|
|
7
7
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"node:path";import{adapterEntry as t,defineStaticHosting as n,perEnv as r,z as
|
|
1
|
+
import e from"node:path";import{adapterEntry as t,defineStaticHosting as n,perEnv as r,reachesUsers as i,z as a}from"shiplane/plugin";import{z as o}from"shiplane";const folderOf=(e,t)=>i(e,t)?null:t,keptBy=({path:e,users:t})=>`!(${[`CNAME`,...e.filter(e=>e!==t)].join(`|`)})`,s=/^(vite|astro|next|nuxt|svelte)\.config\.(ts|js|mjs|cjs)$/,c=a.object({url:a.string().regex(/^https?:\/\/[^/]+/,`the site's address, like https://acme.github.io/site/`).describe(`The site's address; its path is given to the build as BASE_PATH`),branch:a.string().default(`gh-pages`).describe(`The branch Pages serves`),dist:a.string().default(`dist`).describe(`What the build writes, relative to the unit's folder`),domain:a.string().optional().describe(`A custom domain, written as CNAME`),env:a.record(a.string(),r(a.string())).optional().describe(`Variables the build reads, per environment`),variables:a.array(a.string().regex(/^[A-Z][A-Z0-9_]*$/,`a variable name is UPPER_SNAKE, like SITE_KEY`)).default([]).describe(`Variables the build reads from this machine or, on CI, from GitHub's variables`)}),addressOf=(e,t,n)=>{let r=e.endsWith(`/`)?e:`${e}/`,i=folderOf(t,n);return i===null?r:`${r}${i}/`},siteOf=e=>{let[t=``,n=``]=e.split(`/`);return n.endsWith(`.github.io`)?`https://${n}/`:`https://${t}.github.io/${n}/`},startBranch=e=>({command:`sh`,args:[`-c`,`[ -z "$GITHUB_ACTIONS" ] || { git config --global user.name "github-actions[bot]" && git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" && git config --global credential.https://github.com.helper "!gh auth git-credential"; } && { git ls-remote --exit-code --heads origin "$1" >/dev/null || git push origin "$(git commit-tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 -m "start $1")":"refs/heads/$1"; }`,`sh`,e]}),githubPagesStaticHosting=()=>n({name:`github-pages`,settings:c,typicalMinutes:2,describe:({options:e,environment:t,flow:n})=>`${addressOf(e.url,n,t)} (GitHub Pages)`,detect:e=>{let t=e.files.find(e=>s.test(e));if(!t)return null;let n=!t.startsWith(`vite.`)||e.has(`index.html`);return{certainty:n?`likely`:`possible`,reason:n&&t.startsWith(`vite.`)?`${t}, index.html`:t,options:{}}},questions:(e,t,n,r)=>t.url===void 0?[{key:`url`,message:`Address of the site?`,...r?{initial:siteOf(r)}:{}}]:[],requirements:e=>{let{variables:t}=c.partial({url:!0}).parse(e.options);return[{label:`GitHub Pages`,check:{command:`git`,args:[`ls-remote`,`--quiet`,`origin`,`HEAD`]},secrets:[`GH_TOKEN`],permissions:{contents:`write`,pages:`write`},...t.length>0?{variables:t}:{}}]},jobs:({unit:t,tag:n,environment:r,options:i,defaultBranch:a,flow:o})=>{let{branch:s,domain:c}=i;if(s===a)throw Error(`${t.name}: branch "${s}" holds the source, and a ship replaces its files. Use another, such as gh-pages.`);let l=addressOf(i.url,o,r),u=folderOf(o,r),d=keptBy(o);return[{label:`build ${n} and publish it to ${l}`,local:[{command:`pnpm`,args:[`--filter=${t.packageName}`,`run`,`build`],env:{BASE_PATH:new URL(l).pathname,...i.env}},startBranch(s),{command:`npx`,args:[`--yes`,`gh-pages@6.3.0`,`--dist=${e.posix.join(t.dir,i.dist)}`,`--branch=${s}`,`--message=${n}`,`--dotfiles`,`--nojekyll`,...c?[`--cname=${c}`]:[],u===null?`--remove={${d},${d}/**}`:`--dest=${u}`]},{command:`sh`,args:[`-c`,`[ -z "$GITHUB_ACTIONS" ] || gh api -X POST "repos/$GITHUB_REPOSITORY/pages/builds" --silent || echo "Pages was not asked to build: ship again, or build it from Settings > Pages"`]}],ci:{ref:n},record:!0}]}}),l=[t({name:`github-pages`,port:`staticHosting`,description:`Deploys each site to GitHub Pages, through a branch`,options:o.object({}),make:()=>githubPagesStaticHosting()})];export{l as catalog,githubPagesStaticHosting};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["z"],"sources":["../src/github-pages-static-hosting.adapter.ts","../src/catalog.ts"],"sourcesContent":["import path from \"node:path\";\nimport type { Command, DeliveryAdapter, StaticHostingPort } from \"shiplane/plugin\";\nimport { defineStaticHosting, perEnv, z } from \"shiplane/plugin\";\n\nconst GH_PAGES = \"gh-pages@6.3.0\";\n\n/** Where preview lives on the branch. Production is the rest of it. */\nconst PREVIEW = \"preview\";\n\n/** Everything at the branch root but these, as a glob. It starts with a brace where it is used: a\n * leading `!` would negate the whole pattern. */\nconst KEPT = `!(CNAME|${PREVIEW})`;\n\nconst BUILT = /^(vite|astro|next|nuxt|svelte)\\.config\\.(ts|js|mjs|cjs)$/;\n\nconst GithubPagesOptions = z.object({\n url: z\n .string()\n .regex(/^https?:\\/\\/[^/]+/, \"the site's address, like https://acme.github.io/site/\")\n .describe(\"The site's address; its path is given to the build as BASE_PATH\"),\n branch: z.string().default(\"gh-pages\").describe(\"The branch Pages serves\"),\n dist: z.string().default(\"dist\").describe(\"What the build writes, relative to the unit's folder\"),\n domain: z.string().optional().describe(\"A custom domain, written as CNAME\"),\n env: z\n .record(z.string(), perEnv(z.string()))\n .optional()\n .describe(\"Variables the build reads, per environment\"),\n variables: z\n .array(z.string().regex(/^[A-Z][A-Z0-9_]*$/, \"a variable name is UPPER_SNAKE, like SITE_KEY\"))\n .default([])\n .describe(\"Variables the build reads from this machine or, on CI, from GitHub's variables\"),\n});\n\nconst addressOf = (url: string, environment: string) => {\n const root = url.endsWith(\"/\") ? url : `${url}/`;\n return environment === PREVIEW ? `${root}${PREVIEW}/` : root;\n};\n\n/** Where GitHub serves a repository's site: a user's or organisation's is named by its address. */\nconst siteOf = (remote: string) => {\n const [owner = \"\", name = \"\"] = remote.split(\"/\");\n return name.endsWith(\".github.io\") ? `https://${name}/` : `https://${owner}.github.io/${name}/`;\n};\n\n// On a branch that does not exist, gh-pages starts from the repository's own files and publishes\n// them. So the branch is there first, empty. An existing one refuses this push: it is not forced.\nconst START =\n // A runner has no identity and no sign-in of its own outside its checkout.\n '[ -z \"$GITHUB_ACTIONS\" ] || { git config --global user.name \"github-actions[bot]\" && git config --global user.email \"41898282+github-actions[bot]@users.noreply.github.com\" && git config --global credential.https://github.com.helper \"!gh auth git-credential\"; } && ' +\n '{ git ls-remote --exit-code --heads origin \"$1\" >/dev/null || git push origin \"$(git commit-tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 -m \"start $1\")\":\"refs/heads/$1\"; }';\n\n// A push made with a workflow's token builds no Pages site: it is asked for. Not asked, or refused,\n// the files are there all the same.\nconst ASK =\n '[ -z \"$GITHUB_ACTIONS\" ] || gh api -X POST \"repos/$GITHUB_REPOSITORY/pages/builds\" --silent || echo \"Pages was not asked to build: ship again, or build it from Settings > Pages\"';\n\nconst startBranch = (branch: string): Command => ({\n command: \"sh\",\n args: [\"-c\", START, \"sh\", branch],\n});\n\n/** A static build on GitHub Pages: preview in its own folder, production in the rest of the branch. */\nexport type GithubPagesStaticHostingAdapter = DeliveryAdapter<StaticHostingPort>;\n\nexport const githubPagesStaticHosting = (): GithubPagesStaticHostingAdapter =>\n defineStaticHosting({\n name: \"github-pages\",\n settings: GithubPagesOptions,\n typicalMinutes: 2,\n describe: ({ options, environment }) => `${addressOf(options.url, environment)} (GitHub Pages)`,\n detect: (folder) => {\n const built = folder.files.find((file) => BUILT.test(file));\n if (!built) return null;\n // A Vite config without an index.html is usually a library, not a site.\n const site = !built.startsWith(\"vite.\") || folder.has(\"index.html\");\n return {\n certainty: site ? \"likely\" : \"possible\",\n reason: site && built.startsWith(\"vite.\") ? `${built}, index.html` : built,\n options: {},\n };\n },\n questions: (_folder, found, _repository, remote) =>\n found.url === undefined\n ? [\n {\n key: \"url\",\n message: \"Address of the site?\",\n ...(remote ? { initial: siteOf(remote) } : {}),\n },\n ]\n : [],\n requirements: (unit) => {\n const { variables } = GithubPagesOptions.partial({ url: true }).parse(unit.options);\n return [\n {\n label: \"GitHub Pages\",\n check: { command: \"git\", args: [\"ls-remote\", \"--quiet\", \"origin\", \"HEAD\"] },\n secrets: [\"GH_TOKEN\"],\n permissions: { contents: \"write\", pages: \"write\" },\n ...(variables.length > 0 ? { variables } : {}),\n },\n ];\n },\n jobs: ({ unit, tag, environment, options, defaultBranch }) => {\n const { branch, domain } = options;\n if (branch === defaultBranch) {\n throw new Error(\n `${unit.name}: branch \"${branch}\" holds the source, and a ship replaces its files. Use another, such as gh-pages.`,\n );\n }\n const address = addressOf(options.url, environment);\n return [\n {\n label: `build ${tag} and publish it to ${address}`,\n local: [\n {\n command: \"pnpm\",\n args: [`--filter=${unit.packageName}`, \"run\", \"build\"],\n env: { BASE_PATH: new URL(address).pathname, ...options.env },\n },\n startBranch(branch),\n {\n command: \"npx\",\n args: [\n \"--yes\",\n GH_PAGES,\n `--dist=${path.posix.join(unit.dir, options.dist)}`,\n `--branch=${branch}`,\n `--message=${tag}`,\n \"--dotfiles\",\n \"--nojekyll\",\n ...(domain ? [`--cname=${domain}`] : []),\n // Each environment replaces its own files only; CNAME outlives both.\n environment === PREVIEW ? `--dest=${PREVIEW}` : `--remove={${KEPT},${KEPT}/**}`,\n ],\n },\n { command: \"sh\", args: [\"-c\", ASK] },\n ],\n ci: { ref: tag },\n record: true,\n },\n ];\n },\n });\n","import type { CatalogEntry } from \"shiplane/plugin\";\nimport { z } from \"shiplane\";\nimport { adapterEntry } from \"shiplane/plugin\";\n\nimport { githubPagesStaticHosting } from \"./github-pages-static-hosting.adapter\";\n\n/** What a shiplane.yml names from this plugin: `staticHosting: github-pages`. */\nexport const catalog: readonly CatalogEntry[] = [\n adapterEntry({\n name: \"github-pages\",\n port: \"staticHosting\",\n description: \"Deploys each site to GitHub Pages, through a branch\",\n options: z.object({}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GACjD,YAAY,IACZ,aAAa,IACb,aACA,aACA,GAAI,EAAS,CAAC,WAAW,IAAS,CAAG,EAAE,CAEvC,IAAgB,EAAU,UAAU,IAAY,aAAa,EAAK,GAAG,EAAK,MAC3E,CACF,CACD,CAAE,QAAS,KAAM,KAAM,CAAC,KAAM,oLAAI,CAAE,CACrC,CACD,GAAI,CAAE,IAAK,EAAK,CAChB,OAAQ,GACT,CACF,EAEJ,CAAC,CCxIS,EAAmC,CAC9C,EAAa,CACX,KAAM,eACN,KAAM,gBACN,YAAa,sDACb,QAASA,EAAE,OAAO,EAAE,CAAC,CACrB,SAAY,0BAA0B,CACvC,CAAC,CACH"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["z"],"sources":["../src/github-pages-static-hosting.adapter.ts","../src/catalog.ts"],"sourcesContent":["import path from \"node:path\";\nimport type { Command, DeliveryAdapter, DeployFlow, StaticHostingPort } from \"shiplane/plugin\";\nimport { defineStaticHosting, perEnv, reachesUsers, z } from \"shiplane/plugin\";\n\nconst GH_PAGES = \"gh-pages@6.3.0\";\n\n/** The folder of the branch an environment lives in; users' is the rest of it. */\nconst folderOf = (flow: DeployFlow, environment: string) =>\n reachesUsers(flow, environment) ? null : environment;\n\n/** Everything at the branch root but CNAME and the other environments' folders, as a glob. It starts\n * with a brace where it is used: a leading `!` would negate the whole pattern. */\nconst keptBy = ({ path: names, users }: DeployFlow) =>\n `!(${[\"CNAME\", ...names.filter((name) => name !== users)].join(\"|\")})`;\n\nconst BUILT = /^(vite|astro|next|nuxt|svelte)\\.config\\.(ts|js|mjs|cjs)$/;\n\nconst GithubPagesOptions = z.object({\n url: z\n .string()\n .regex(/^https?:\\/\\/[^/]+/, \"the site's address, like https://acme.github.io/site/\")\n .describe(\"The site's address; its path is given to the build as BASE_PATH\"),\n branch: z.string().default(\"gh-pages\").describe(\"The branch Pages serves\"),\n dist: z.string().default(\"dist\").describe(\"What the build writes, relative to the unit's folder\"),\n domain: z.string().optional().describe(\"A custom domain, written as CNAME\"),\n env: z\n .record(z.string(), perEnv(z.string()))\n .optional()\n .describe(\"Variables the build reads, per environment\"),\n variables: z\n .array(z.string().regex(/^[A-Z][A-Z0-9_]*$/, \"a variable name is UPPER_SNAKE, like SITE_KEY\"))\n .default([])\n .describe(\"Variables the build reads from this machine or, on CI, from GitHub's variables\"),\n});\n\nconst addressOf = (url: string, flow: DeployFlow, environment: string) => {\n const root = url.endsWith(\"/\") ? url : `${url}/`;\n const folder = folderOf(flow, environment);\n return folder === null ? root : `${root}${folder}/`;\n};\n\n/** Where GitHub serves a repository's site: a user's or organisation's is named by its address. */\nconst siteOf = (remote: string) => {\n const [owner = \"\", name = \"\"] = remote.split(\"/\");\n return name.endsWith(\".github.io\") ? `https://${name}/` : `https://${owner}.github.io/${name}/`;\n};\n\n// On a branch that does not exist, gh-pages starts from the repository's own files and publishes\n// them. So the branch is there first, empty. An existing one refuses this push: it is not forced.\nconst START =\n // A runner has no identity and no sign-in of its own outside its checkout.\n '[ -z \"$GITHUB_ACTIONS\" ] || { git config --global user.name \"github-actions[bot]\" && git config --global user.email \"41898282+github-actions[bot]@users.noreply.github.com\" && git config --global credential.https://github.com.helper \"!gh auth git-credential\"; } && ' +\n '{ git ls-remote --exit-code --heads origin \"$1\" >/dev/null || git push origin \"$(git commit-tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 -m \"start $1\")\":\"refs/heads/$1\"; }';\n\n// A push made with a workflow's token builds no Pages site: it is asked for. Not asked, or refused,\n// the files are there all the same.\nconst ASK =\n '[ -z \"$GITHUB_ACTIONS\" ] || gh api -X POST \"repos/$GITHUB_REPOSITORY/pages/builds\" --silent || echo \"Pages was not asked to build: ship again, or build it from Settings > Pages\"';\n\nconst startBranch = (branch: string): Command => ({\n command: \"sh\",\n args: [\"-c\", START, \"sh\", branch],\n});\n\n/** A static build on GitHub Pages: each environment in its own folder, users' in the rest of the branch. */\nexport type GithubPagesStaticHostingAdapter = DeliveryAdapter<StaticHostingPort>;\n\nexport const githubPagesStaticHosting = (): GithubPagesStaticHostingAdapter =>\n defineStaticHosting({\n name: \"github-pages\",\n settings: GithubPagesOptions,\n typicalMinutes: 2,\n describe: ({ options, environment, flow }) =>\n `${addressOf(options.url, flow, environment)} (GitHub Pages)`,\n detect: (folder) => {\n const built = folder.files.find((file) => BUILT.test(file));\n if (!built) return null;\n // A Vite config without an index.html is usually a library, not a site.\n const site = !built.startsWith(\"vite.\") || folder.has(\"index.html\");\n return {\n certainty: site ? \"likely\" : \"possible\",\n reason: site && built.startsWith(\"vite.\") ? `${built}, index.html` : built,\n options: {},\n };\n },\n questions: (_folder, found, _repository, remote) =>\n found.url === undefined\n ? [\n {\n key: \"url\",\n message: \"Address of the site?\",\n ...(remote ? { initial: siteOf(remote) } : {}),\n },\n ]\n : [],\n requirements: (unit) => {\n const { variables } = GithubPagesOptions.partial({ url: true }).parse(unit.options);\n return [\n {\n label: \"GitHub Pages\",\n check: { command: \"git\", args: [\"ls-remote\", \"--quiet\", \"origin\", \"HEAD\"] },\n secrets: [\"GH_TOKEN\"],\n permissions: { contents: \"write\", pages: \"write\" },\n ...(variables.length > 0 ? { variables } : {}),\n },\n ];\n },\n jobs: ({ unit, tag, environment, options, defaultBranch, flow }) => {\n const { branch, domain } = options;\n if (branch === defaultBranch) {\n throw new Error(\n `${unit.name}: branch \"${branch}\" holds the source, and a ship replaces its files. Use another, such as gh-pages.`,\n );\n }\n const address = addressOf(options.url, flow, environment);\n const folder = folderOf(flow, environment);\n const kept = keptBy(flow);\n return [\n {\n label: `build ${tag} and publish it to ${address}`,\n local: [\n {\n command: \"pnpm\",\n args: [`--filter=${unit.packageName}`, \"run\", \"build\"],\n env: { BASE_PATH: new URL(address).pathname, ...options.env },\n },\n startBranch(branch),\n {\n command: \"npx\",\n args: [\n \"--yes\",\n GH_PAGES,\n `--dist=${path.posix.join(unit.dir, options.dist)}`,\n `--branch=${branch}`,\n `--message=${tag}`,\n \"--dotfiles\",\n \"--nojekyll\",\n ...(domain ? [`--cname=${domain}`] : []),\n // Each environment replaces its own files only; CNAME outlives both.\n folder === null ? `--remove={${kept},${kept}/**}` : `--dest=${folder}`,\n ],\n },\n { command: \"sh\", args: [\"-c\", ASK] },\n ],\n ci: { ref: tag },\n record: true,\n },\n ];\n },\n });\n","import type { CatalogEntry } from \"shiplane/plugin\";\nimport { z } from \"shiplane\";\nimport { adapterEntry } from \"shiplane/plugin\";\n\nimport { githubPagesStaticHosting } from \"./github-pages-static-hosting.adapter\";\n\n/** What a shiplane.yml names from this plugin: `staticHosting: github-pages`. */\nexport const catalog: readonly CatalogEntry[] = [\n adapterEntry({\n name: \"github-pages\",\n port: \"staticHosting\",\n description: \"Deploys each site to GitHub Pages, through a branch\",\n options: z.object({}),\n make: () => githubPagesStaticHosting(),\n }),\n];\n"],"mappings":"mKAIA,MAGM,UAAY,EAAkB,IAClC,EAAa,EAAM,EAAY,CAAG,KAAO,EAIrC,QAAU,CAAE,KAAM,EAAO,WAC7B,KAAK,CAAC,QAAS,GAAG,EAAM,OAAQ,GAAS,IAAS,EAAM,CAAC,CAAC,KAAK,IAAI,CAAC,GAEhE,EAAQ,2DAER,EAAqB,EAAE,OAAO,CAClC,IAAK,EACF,QAAQ,CACR,MAAM,oBAAqB,wDAAwD,CACnF,SAAS,kEAAkE,CAC9E,OAAQ,EAAE,QAAQ,CAAC,QAAQ,WAAW,CAAC,SAAS,0BAA0B,CAC1E,KAAM,EAAE,QAAQ,CAAC,QAAQ,OAAO,CAAC,SAAS,uDAAuD,CACjG,OAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,oCAAoC,CAC3E,IAAK,EACF,OAAO,EAAE,QAAQ,CAAE,EAAO,EAAE,QAAQ,CAAC,CAAC,CACtC,UAAU,CACV,SAAS,6CAA6C,CACzD,UAAW,EACR,MAAM,EAAE,QAAQ,CAAC,MAAM,oBAAqB,gDAAgD,CAAC,CAC7F,QAAQ,EAAE,CAAC,CACX,SAAS,iFAAiF,CAC9F,CAAC,CAEI,WAAa,EAA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
-
"description": "GitHub Pages plugin for shiplane: deploy a static site and
|
|
3
|
+
"version": "0.6.0-nightly.16",
|
|
4
|
+
"description": "GitHub Pages plugin for shiplane: deploy a static site, and one per environment, to one branch.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shiplane",
|
|
7
7
|
"github-pages",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"prettier": "^3.10.1",
|
|
40
40
|
"typescript": "6.0.3",
|
|
41
41
|
"vitest": "^5.1.0",
|
|
42
|
-
"shiplane": "0.6.0-nightly.
|
|
42
|
+
"shiplane": "0.6.0-nightly.16"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"shiplane": "0.6.0-nightly.
|
|
45
|
+
"shiplane": "0.6.0-nightly.16"
|
|
46
46
|
},
|
|
47
47
|
"shiplane": {
|
|
48
48
|
"adapters": [
|