@smoothdeploy/mainsail 0.1.0-beta.2 → 0.1.0-beta.4
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 +18 -37
- package/dist/cli.js +38 -31
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,28 +1,38 @@
|
|
|
1
1
|
# mainsail
|
|
2
2
|
|
|
3
|
-
Run your Playwright tests on SmoothDeploy from a terminal or a CI job. `mainsail test` packs
|
|
3
|
+
Run your Playwright tests on SmoothDeploy from a terminal or a CI job. `mainsail test` packs your test code, uploads it, starts a run, waits for the result and prints a summary with links to the run and the report.
|
|
4
4
|
|
|
5
5
|
Node 22 or newer. No runtime dependencies.
|
|
6
6
|
|
|
7
7
|
## Install and run
|
|
8
8
|
|
|
9
|
+
On your machine:
|
|
10
|
+
|
|
9
11
|
```bash
|
|
10
12
|
npm install -D @smoothdeploy/mainsail
|
|
11
|
-
|
|
12
|
-
export SMOOTHDEPLOY_PROJECT_ID=3f8a1b2c-...
|
|
13
|
+
npx mainsail login
|
|
13
14
|
npx mainsail test
|
|
14
15
|
```
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
`mainsail login` opens the browser to approve the sign-in, then asks which SmoothDeploy project to use and saves both. With one project it picks that project without asking. Change the project later with `mainsail project`, or `mainsail project <name or id>` to skip the prompt. `mainsail whoami` prints the user, organization and project; `mainsail logout` revokes and deletes the credential.
|
|
18
|
+
|
|
19
|
+
Run `mainsail test` in the directory that holds `playwright.config.*`. In a monorepo, run it in the test package: the CLI walks up to the lockfile, packs from there and tells the runner where the tests are.
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
In CI there is no browser, so use an API key:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
export SMOOTHDEPLOY_API_KEY=sd_...
|
|
25
|
+
npx mainsail test
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Create the API key under **Operations → API Keys** with the **Test Runs** `create` and `read` scopes. The CLI finds the SmoothDeploy project on its own when the key also has the **Projects** `read` scope and can see exactly one active project: the key is restricted to one project, or the organization has one project. Otherwise set `SMOOTHDEPLOY_PROJECT_ID` to the ID of the project.
|
|
19
29
|
|
|
20
30
|
## Environment
|
|
21
31
|
|
|
22
32
|
| Variable | Meaning |
|
|
23
33
|
|---|---|
|
|
24
|
-
| `SMOOTHDEPLOY_API_KEY` | API key
|
|
25
|
-
| `SMOOTHDEPLOY_PROJECT_ID` | UUID of the project
|
|
34
|
+
| `SMOOTHDEPLOY_API_KEY` | API key. Used instead of the `mainsail login` credential when set. Never printed: any occurrence in output is replaced by `***`. |
|
|
35
|
+
| `SMOOTHDEPLOY_PROJECT_ID` | UUID of the SmoothDeploy project. Used instead of the project saved by `mainsail login` when set. |
|
|
26
36
|
| `SMOOTHDEPLOY_API_URL` | API base URL. Default `https://api.smoothdeploy.com`. |
|
|
27
37
|
| `SMOOTHDEPLOY_COMMIT_SHA` | Commit to record on the run. Overrides detection. 7 to 64 hex characters. |
|
|
28
38
|
| `SMOOTHDEPLOY_BRANCH` | Branch to record on the run. Overrides detection. |
|
|
@@ -48,7 +58,7 @@ npx mainsail secret set DB_PASSWORD
|
|
|
48
58
|
printf %s "$VALUE" | npx mainsail secret set DB_PASSWORD
|
|
49
59
|
```
|
|
50
60
|
|
|
51
|
-
`secret set` saves a secret. The value is encrypted on this machine before upload: the CLI fetches a public key (`secrets.public-key`), encrypts the value with AES-256-GCM under a fresh key, wraps that key with RSA-OAEP-SHA256 and sends only the result (`secrets.set`). The encryption is bound to the name and the project. On a terminal the value is read from a hidden prompt; otherwise all of stdin is read and one trailing newline is dropped. The value is never read from a flag, an environment variable or a config file. The secret is saved in the
|
|
61
|
+
`secret set` saves a secret. The value is encrypted on this machine before upload: the CLI fetches a public key (`secrets.public-key`), encrypts the value with AES-256-GCM under a fresh key, wraps that key with RSA-OAEP-SHA256 and sends only the result (`secrets.set`). The encryption is bound to the name and the project. On a terminal the value is read from a hidden prompt; otherwise all of stdin is read and one trailing newline is dropped. The value is never read from a flag, an environment variable or a config file. The secret is saved in the selected SmoothDeploy project, and an existing name in that project is replaced. The API key needs the **Test Runs** `create` scope; a key restricted to a project can set secrets of that project only. Names the runner relies on are reserved (`PATH`, `HOME`, `CI`, `NODE_*`, `PLAYWRIGHT_*`, `LD_*` and others) and are refused.
|
|
52
62
|
|
|
53
63
|
## Exit codes
|
|
54
64
|
|
|
@@ -121,32 +131,3 @@ e2e:
|
|
|
121
131
|
The HTTP calls behind the CLI are documented in the [Run API reference](https://docs.smoothdeploy.com/api-reference/test-runs).
|
|
122
132
|
|
|
123
133
|
The summary prints the report link. It is a signed link: anyone who can read the CI log can open the report until the link expires. Keep that in mind for public CI logs.
|
|
124
|
-
|
|
125
|
-
## Development
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
pnpm --filter @smoothdeploy/mainsail build
|
|
129
|
-
pnpm --filter @smoothdeploy/mainsail test
|
|
130
|
-
bash scripts/cli-pack-check.sh
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
`cli-pack-check.sh` packs the CLI, installs the tarball in an empty directory and runs it.
|
|
134
|
-
|
|
135
|
-
## Release
|
|
136
|
-
|
|
137
|
-
The CLI has its own version, changelog and tag. On `master`:
|
|
138
|
-
|
|
139
|
-
```bash
|
|
140
|
-
pnpm cli bump
|
|
141
|
-
git push --follow-tags origin master
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
`bump` bumps the version from the commits that touch `apps/mainsail`, writes `CHANGELOG.md` and creates the tag `mainsail-v<version>`. The tag starts the `Release CLI` workflow, which publishes to npm through trusted publishing. No npm token is stored.
|
|
145
|
-
|
|
146
|
-
The version decides the npm channel:
|
|
147
|
-
|
|
148
|
-
| Command | Version | Channel | Install |
|
|
149
|
-
|---|---|---|---|
|
|
150
|
-
| `pnpm cli bump` | `0.2.0` | `latest` | `npm install -D @smoothdeploy/mainsail` |
|
|
151
|
-
| `pnpm cli bump --prerelease beta` | `0.2.0-beta.0` | `beta` | `npm install -D @smoothdeploy/mainsail@beta` |
|
|
152
|
-
| `pnpm cli bump --prerelease alpha` | `0.2.0-alpha.0` | `next` | `npm install -D @smoothdeploy/mainsail@next` |
|
package/dist/cli.js
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{spawn as
|
|
3
|
-
`,{mode:384,flag:"wx"}),
|
|
4
|
-
`).match(/version:\s*(\d[^\s(]*)/)?.[1],a=i??c;if(a)return[a]}return r}function
|
|
2
|
+
import{spawn as Pt,spawnSync as bt}from"node:child_process";import{mkdtempSync as kt,readFileSync as Ut,readdirSync as Ct,rmSync as De}from"node:fs";import{readFile as jt}from"node:fs/promises";import{hostname as Lt,tmpdir as At}from"node:os";import P from"node:path";import{createInterface as Dt}from"node:readline";import{parseArgs as Nt}from"node:util";import{createReadStream as Ke}from"node:fs";import Ge from"node:http";import Fe from"node:https";var w=class extends Error{constructor(n,r,s,o){super(s);this.status=n;this.code=r;this.details=o}status;code;details};function $(e,t,n,r){let s={...t&&{"x-api-key":t},...n&&{"x-project-id":n}};async function o(i,c){let a=new URL(`/v1/actions/${i}`,e);for(let[m,g]of Object.entries(c.query??{}))a.searchParams.set(m,g);let l;try{l=await fetch(a,{method:c.method,headers:{...s,"content-type":"application/json",accept:"application/json","user-agent":r},body:c.body?JSON.stringify(c.body):void 0,signal:AbortSignal.timeout(3e4)})}catch(m){let g=m;throw new w(0,"network_error",`Could not reach ${a.origin}: ${g.cause?.message??g.message}`)}let f=await l.text(),d={};try{d=JSON.parse(f)}catch{if(l.ok)throw new w(l.status,"bad_response",`${a.origin} answered with something that is not JSON. Check SMOOTHDEPLOY_API_URL.`)}if(!l.ok)throw new w(l.status,d.errorCode??`http_${l.status}`,d.error??`HTTP ${l.status}`,d.details);return d.data}return{post:(i,c)=>o(i,{method:"POST",body:c}),get:(i,c)=>o(i,{method:"GET",query:c})}}function ce(e,t,n,r,s){return new Promise((o,i)=>{let c=new URL(e),a=(c.protocol==="https:"?Fe:Ge).request(c,{method:"PUT",headers:t,timeout:12e4},d=>{let m="";d.setEncoding("utf8"),d.on("data",g=>m+=g.slice(0,4096)),d.on("end",()=>{if(d.statusCode&&d.statusCode<300)return o();let g=d.statusCode===403&&/expired/i.test(m);i(new w(d.statusCode??0,g?"upload_expired":"upload_failed",g?"The upload link expired":`The storage server answered HTTP ${d.statusCode}`))})});a.on("timeout",()=>a.destroy(new Error("no response for 2 minutes"))),a.on("error",d=>i(new w(0,"upload_failed",d.message)));let l=0,f=Ke(n);f.on("data",d=>{l+=d.length,s(Math.min(l,r))}),f.on("error",d=>a.destroy(d)),f.pipe(a)})}import{execFileSync as We}from"node:child_process";import{readFileSync as Ve}from"node:fs";var le=e=>e?.startsWith("refs/heads/")?e.slice(11):void 0;function qe(e){if(!(!e.GITHUB_EVENT_NAME?.startsWith("pull_request")||!e.GITHUB_EVENT_PATH))try{return JSON.parse(Ve(e.GITHUB_EVENT_PATH,"utf8")).pull_request?.head?.sha}catch{return}}var Xe=[{name:"GitHub Actions",detect:"GITHUB_ACTIONS",read:e=>({commitSha:qe(e)??e.GITHUB_SHA,branch:e.GITHUB_HEAD_REF||e.GITHUB_REF_NAME,ciUrl:e.GITHUB_SERVER_URL&&e.GITHUB_REPOSITORY&&e.GITHUB_RUN_ID?`${e.GITHUB_SERVER_URL}/${e.GITHUB_REPOSITORY}/actions/runs/${e.GITHUB_RUN_ID}`:void 0})},{name:"GitLab CI",detect:"GITLAB_CI",read:e=>({commitSha:e.CI_COMMIT_SHA,branch:e.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME||e.CI_COMMIT_REF_NAME,ciUrl:e.CI_JOB_URL})},{name:"CircleCI",detect:"CIRCLECI",read:e=>({commitSha:e.CIRCLE_SHA1,branch:e.CIRCLE_BRANCH,ciUrl:e.CIRCLE_BUILD_URL})},{name:"Bitbucket Pipelines",detect:"BITBUCKET_BUILD_NUMBER",read:e=>({commitSha:e.BITBUCKET_COMMIT,branch:e.BITBUCKET_BRANCH,ciUrl:e.BITBUCKET_REPO_FULL_NAME?`https://bitbucket.org/${e.BITBUCKET_REPO_FULL_NAME}/pipelines/results/${e.BITBUCKET_BUILD_NUMBER}`:void 0})},{name:"Azure Pipelines",detect:"TF_BUILD",read:e=>({commitSha:e.BUILD_SOURCEVERSION,branch:le(e.SYSTEM_PULLREQUEST_SOURCEBRANCH)??le(e.BUILD_SOURCEBRANCH),ciUrl:e.SYSTEM_COLLECTIONURI&&e.SYSTEM_TEAMPROJECT&&e.BUILD_BUILDID?`${e.SYSTEM_COLLECTIONURI.replace(/\/?$/,"/")}${encodeURIComponent(e.SYSTEM_TEAMPROJECT)}/_build/results?buildId=${e.BUILD_BUILDID}`:void 0})},{name:"Jenkins",detect:"JENKINS_URL",read:e=>({commitSha:e.GIT_COMMIT,branch:e.CHANGE_BRANCH||e.BRANCH_NAME||e.GIT_BRANCH?.replace(/^origin\//,""),ciUrl:e.BUILD_URL})},{name:"Buildkite",detect:"BUILDKITE",read:e=>({commitSha:e.BUILDKITE_COMMIT,branch:e.BUILDKITE_BRANCH,ciUrl:e.BUILDKITE_BUILD_URL})}];function de(e,t){try{return We("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],windowsHide:!0}).trim()||void 0}catch{return}}var F=e=>e&&/^[0-9a-f]{7,64}$/i.test(e)?e:void 0,W=e=>e&&e.length<=255?e:void 0,ue=e=>e&&e.length<=2048&&URL.canParse(e)&&/^https?:$/.test(new URL(e).protocol)?e:void 0;function pe(e,t,n){let r=Xe.find(i=>e[i.detect]),s=r?.read(e)??{},o=(i,c,a)=>{if(c)return a(c)||n(`Ignoring ${i}: "${c}" is not valid.`),a(c)};return{provider:r?.name,commitSha:o("SMOOTHDEPLOY_COMMIT_SHA",e.SMOOTHDEPLOY_COMMIT_SHA,F)??F(s.commitSha)??F(de(t,["rev-parse","HEAD"])),branch:o("SMOOTHDEPLOY_BRANCH",e.SMOOTHDEPLOY_BRANCH,W)??W(s.branch)??W(de(t,["symbolic-ref","--short","-q","HEAD"])),ciUrl:o("SMOOTHDEPLOY_CI_URL",e.SMOOTHDEPLOY_CI_URL,ue)??ue(s.ciUrl)}}import{chmodSync as Qe,mkdirSync as Ze,readFileSync as et,rmSync as fe,writeFileSync as tt}from"node:fs";import{homedir as nt}from"node:os";import V from"node:path";function j(e){let t=process.platform==="win32"&&e.APPDATA?e.APPDATA:e.XDG_CONFIG_HOME||V.join(nt(),".config");return V.join(t,"mainsail",".credentials.json")}function M(e){let t;try{t=JSON.parse(et(j(e),"utf8"))}catch{return null}return!t?.apiUrl||!t.token?null:{apiUrl:t.apiUrl,token:t.token,...t.projectId&&{projectId:t.projectId}}}function H(e,t){let n=j(e);return Ze(V.dirname(n),{recursive:!0,mode:448}),fe(n,{force:!0}),tt(n,`${JSON.stringify(t)}
|
|
3
|
+
`,{mode:384,flag:"wx"}),Qe(n,384),n}function q(e){fe(j(e),{force:!0})}import{promises as rt}from"node:fs";import X from"node:path";var ge=["package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb"],S=class extends Error{};async function he(e,t){for(let n=e;;n=X.dirname(n)){let r=new Set(await rt.readdir(n)),s=ge.find(o=>r.has(o));if(s)return{dir:n,name:s};if(r.has("npm-shrinkwrap.json"))throw new S(`npm-shrinkwrap.json is not supported. Use package-lock.json instead (${X.join(n,"npm-shrinkwrap.json")}).`);if(n===t||X.dirname(n)===n)throw new S(`No lockfile found in ${e} or its parent directories. Commit one of ${ge.slice(0,4).join(", ")} by running your package manager's install.`)}}var E="@playwright/test",Q=e=>[...new Set(e)];function it(e,t){let n=JSON.parse(e),s=(t==="."?void 0:n.packages?.[`${t}/node_modules/${E}`]?.version)??n.packages?.[`node_modules/${E}`]?.version??n.dependencies?.[E]?.version;return s?[s]:[]}function st(e,t){let n=e.split(/\r?\n/),r=Q(n.flatMap(o=>o.match(/^\s+'?\/?@playwright\/test[@/](\d[^:'(\s]*)/)?.[1]??[]));if(r.length<=1)return r;let s=n.findIndex(o=>o===` ${t}:`||o===` '${t}':`);if(s===-1)return r;for(let o=s+1;o<n.length&&/^\s{3,}|^$/.test(n[o]);o++){if(!/^\s+'?@playwright\/test'?:/.test(n[o]))continue;let i=n[o].match(/:\s*(\d[^\s(]*)/)?.[1],c=n.slice(o+1,o+3).join(`
|
|
4
|
+
`).match(/version:\s*(\d[^\s(]*)/)?.[1],a=i??c;if(a)return[a]}return r}function ot(e){let t=[],n=!1;for(let r of e.split(/\r?\n/)){/^\s/.test(r)||(n=r.includes(`${E}@`));let s=n&&r.match(/^\s+version:?\s+"?([^"\s]+)"?/)?.[1];s&&t.push(s)}return Q(t)}var at=e=>Q([...e.matchAll(/"@playwright\/test@(\d[^"]*)"/g)].map(t=>t[1]));function me(e,t,n){if(e==="bun.lockb")throw new S("bun.lockb is binary and cannot be read. Run `bun install --save-text-lockfile` to create bun.lock, commit it, and run again.");let r=e==="package-lock.json"?it(t,n):e==="pnpm-lock.yaml"?st(t,n):e==="yarn.lock"?ot(t):at(t);if(r.length===0)throw new S(`${e} has no ${E}. Add it with your package manager, for example \`npm install -D ${E}\`.`);if(r.length>1)throw new S(`${e} has several ${E} versions (${r.join(", ")}). Use one version across the project.`);let[s]=r;if(!/^\d+\.\d+\.\d+$/.test(s))throw new S(`${E} ${s} is a pre-release. Use a released version.`);return s}var we=[];function R(e){e&&we.push(e)}var L=e=>we.reduce((t,n)=>t.replaceAll(n,"***"),e);function B(e,t){let n=e?process.stderr:process.stdout,r=!!n.isTTY&&!t.NO_COLOR&&t.TERM!=="dumb",s=!!n.isTTY&&!t.CI,o=!1,i=a=>l=>r?`\x1B[${a}m${l}\x1B[0m`:l,c=()=>{o&&n.write("\r\x1B[2K"),o=!1};return{live:s,green:i(32),red:i(31),yellow:i(33),dim:i(2),bold:i(1),line(a=""){c(),n.write(`${L(a)}
|
|
5
5
|
`)},status(a){if(!s)return void n.write(`${L(a)}
|
|
6
6
|
`);n.write(`\r\x1B[2K${L(a)}`),o=!0},error(a){c(),process.stderr.write(`${L(a)}
|
|
7
7
|
`)},json(a){process.stdout.write(`${L(JSON.stringify(a,null,2))}
|
|
8
|
-
`)},done:c}}import{execFile as
|
|
9
|
-
`,r=Buffer.byteLength(n);for(;String(r).length+Buffer.byteLength(n)!==r;)r=String(r).length+Buffer.byteLength(n);return`${r}${n}`}function
|
|
8
|
+
`)},done:c}}import{execFile as ut}from"node:child_process";import{createWriteStream as pt,promises as D}from"node:fs";import I from"node:path";import{Readable as ft}from"node:stream";import{pipeline as gt}from"node:stream/promises";import{promisify as ht}from"node:util";import{createGzip as mt}from"node:zlib";function ct(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(r==="*"&&e[n+1]==="*"){let s=n===0||e[n-1]==="/",o=n+2===e.length||e[n+2]==="/";if(s&&o){t+=n+2===e.length?".*":"(?:.*/)?",n+=2;continue}}if(r==="*")t+="[^/]*";else if(r==="?")t+="[^/]";else if(r==="\\"&&n+1<e.length)t+=`\\${e[++n]}`;else if(r==="["){let s=e.indexOf("]",n+2);if(s===-1)t+="\\[";else{let o=e.slice(n+1,s).replace(/^!/,"^").replace(/\\/g,"\\\\");t+=`[${o}]`,n=s}}else t+=r.replace(/[.+^${}()|\]\\]/g,"\\$&")}return t}function ye(e){let t=[];for(let n of e.split(/\r?\n/)){let r=n.replace(/(?<!\\)\s+$/,"");if(!r||r.startsWith("#"))continue;let s=r.startsWith("!");s&&(r=r.slice(1)),(r.startsWith("\\#")||r.startsWith("\\!"))&&(r=r.slice(1));let o=r.endsWith("/");o&&(r=r.slice(0,-1));let i=r.includes("/");r.startsWith("/")&&(r=r.slice(1)),r&&t.push({regex:new RegExp(`${i?"^":"(?:^|/)"}${ct(r)}$`),negate:s,dirOnly:o})}return t}function Se(e,t,n){let r;for(let s of e)s.dirOnly&&!n||s.regex.test(t)&&(r=!s.negate);return r}import{createReadStream as lt}from"node:fs";var A=512;function k(e,t){return e.toString(8).padStart(t-1,"0")+"\0"}function _e(e,t){let n=` ${e}=${t}
|
|
9
|
+
`,r=Buffer.byteLength(n);for(;String(r).length+Buffer.byteLength(n)!==r;)r=String(r).length+Buffer.byteLength(n);return`${r}${n}`}function Z(e,t,n,r,s,o=""){let i=Buffer.alloc(A);i.write(e,0,100,"utf8"),i.write(k(n,8),100,"ascii"),i.write(k(0,8),108,"ascii"),i.write(k(0,8),116,"ascii"),i.write(k(t,12),124,"ascii"),i.write(k(r,12),136,"ascii"),i.fill(" ",148,156),i.write(s,156,"ascii"),i.write(o,157,100,"utf8"),i.write("ustar\0",257,"ascii"),i.write("00",263,"ascii");let c=0;for(let a of i)c+=a;return i.write(k(c,7)+" ",148,"ascii"),i}var Te=e=>Buffer.byteLength(e)<=100&&/^[\x20-\x7e]*$/.test(e),$e=e=>Buffer.alloc((A-e%A)%A);function*dt(e){let t="linkTarget"in e?e.linkTarget:"";if(!Te(e.name)||!Te(t)){let r=Buffer.from(_e("path",e.name)+(t?_e("linkpath",t):""));yield Z("PaxHeader",r.length,420,e.mtime,"x"),yield r,yield $e(r.length)}let n=e.name.slice(0,100);"linkTarget"in e?yield Z(n,0,511,e.mtime,"2",t.slice(0,100)):yield Z(n,e.size,e.mode,e.mtime,"0")}async function*Ee(e){for(let t of e){if(yield*dt(t),"linkTarget"in t)continue;let n=0;for await(let r of lt(t.source)){if(n+=r.length,n>t.size)break;yield r}if(n!==t.size)throw new Error(`${t.name} changed while it was being packed. Run again.`);yield $e(t.size)}yield Buffer.alloc(A*2)}var ee=250*1024**2,wt=ht(ut),Oe=e=>e.split("/").some(t=>t==="node_modules"||t===".git"||t===".env"||t.startsWith(".env."));async function yt(e){let n=await wt("git",["ls-files","-z","--cached","--others","--exclude-standard"],{cwd:e,maxBuffer:1073741824,windowsHide:!0}).catch(()=>null);return n?[...new Set(n.stdout.split("\0").filter(Boolean))]:null}function St(e,t,n){let r=!1;for(let{base:s,rules:o}of e){let i=Se(o,s?t.slice(s.length+1):t,n);i!==void 0&&(r=i)}return r}async function Re(e,t="",n=[]){let r=await D.readdir(I.join(e,t),{withFileTypes:!0}),o=r.find(c=>c.name===".gitignore"&&c.isFile())?[...n,{base:t,rules:ye(await D.readFile(I.join(e,t,".gitignore"),"utf8"))}]:n,i=[];for(let c of r){let a=t?`${t}/${c.name}`:c.name;Oe(a)||St(o,a,c.isDirectory())||(c.isDirectory()?i.push(...await Re(e,a,o)):i.push(a))}return i}var _t=(e,t)=>{let n=I.posix.normalize(I.posix.join(I.posix.dirname(e),t));return I.posix.isAbsolute(t)||/^[a-zA-Z]:/.test(t)||n===".."||n.startsWith("../")};async function Ie(e){let t=await yt(e),n=(t??await Re(e)).filter(i=>!Oe(i)).sort(),r=[],s=[],o=0;for(let i of n){let c=I.join(e,i),a=await D.lstat(c).catch(()=>null);if(!a)continue;let l=Math.floor(a.mtimeMs/1e3);if(a.isSymbolicLink()){let f=(await D.readlink(c)).replaceAll("\\","/");_t(i,f)?s.push(i):r.push({name:i,linkTarget:f,mtime:l});continue}a.isFile()&&(r.push({name:i,source:c,size:a.size,mode:a.mode&73?493:420,mtime:l}),o+=a.size)}return{entries:r,bytes:o,git:t!==null,skippedLinks:s}}async function Pe(e,t){return await gt(ft.from(Ee(e)),mt(),pt(t)),(await D.stat(t)).size}function be(e,t=5){let n=new Map,r=[];for(let o of e){if(!("size"in o))continue;r.push([o.name,o.size]);let i=o.name.indexOf("/");i>0&&n.set(o.name.slice(0,i+1),(n.get(o.name.slice(0,i+1))??0)+o.size)}let s=o=>o.sort((i,c)=>c[1]-i[1]).slice(0,t);return{dirs:s([...n]),files:s(r)}}import{constants as Tt,createCipheriv as $t,publicEncrypt as Et,randomBytes as ke}from"node:crypto";var Ot=(e,t)=>Buffer.from(`smoothdeploy-secret/v1\0${e}\0${t}`,"utf8");function Ue(e,t,n,r){let s=ke(32),o=ke(12);try{let i=$t("aes-256-gcm",s,o,{authTagLength:16});i.setAAD(Ot(t,n));let c=Buffer.concat([i.update(r,"utf8"),i.final()]);return{encryptedKey:Et({key:e,padding:Tt.RSA_PKCS1_OAEP_PADDING,oaepHash:"sha256"},s).toString("base64"),iv:o.toString("base64"),ciphertext:c.toString("base64"),tag:i.getAuthTag().toString("base64")}}finally{s.fill(0)}}function Y(e){let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}var Rt=e=>`${[e.file,...e.describePath,e.title].filter(Boolean).join(" \u203A ")}${e.projectName?` [${e.projectName}]`:""}`;function Ce(e,t,n,r){if(n.length!==0){e.line(),e.line(e.bold(t));for(let s of n.slice(0,20)){e.line(` ${Rt(s)}`);for(let o of r(s))e.line(e.dim(` ${o}`))}n.length>20&&e.line(` and ${n.length-20} more on the run page`)}}var It=e=>(e.error??"").split(/\r?\n/).filter(t=>t.trim()).slice(0,6);function je(e,t){let{passed:n,failed:r,flaky:s,skipped:o}=t.counts,i=[r&&e.red(`${r} failed`),`${n} passed`,s&&e.yellow(`${s} flaky`),o&&`${o} skipped`].filter(Boolean),c=t.durationMs?` in ${Y(t.durationMs)}`:"";Ce(e,"Failed tests",t.tests.filter(a=>a.status==="failed"),It),Ce(e,"Flaky tests (passed on retry)",t.tests.filter(a=>a.status==="flaky"),a=>[`passed after ${a.retries} ${a.retries===1?"retry":"retries"}`]),t.testsTruncated&&(e.line(),e.line(`Only the first ${t.tests.length} test results are listed. See the run page for all of them.`)),e.line(),t.status==="completed"?e.line(`${e.green(e.bold("Passed"))} ${i.join(", ")}${c}`):t.status==="cancelled"?e.line(`${e.yellow(e.bold("Cancelled"))} The run was cancelled before it finished.`):t.failureReason?e.line(`${e.red(e.bold("Could not run the tests"))} ${t.failureReason}`):e.line(`${e.red(e.bold("Failed"))} ${i.join(", ")}${c}`),t.reportUrl&&e.line(`Report ${t.reportUrl}`),e.line(`Run ${t.url}`)}var ne=JSON.parse(Ut(new URL("../package.json",import.meta.url),"utf8")),p="mainsail",b=`${p}/${ne.version}`,h={passed:0,failed:1,error:2,interrupted:130},Le={micro:1,small:2,medium:4,large:8},re="https://api.smoothdeploy.com",vt=[".ts",".js",".mts",".mjs",".cts",".cjs"].map(e=>`playwright.config${e}`),xt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Ne=6,z=`${p} ${ne.version}: run your Playwright tests on SmoothDeploy.
|
|
10
10
|
|
|
11
11
|
Usage
|
|
12
|
-
${
|
|
13
|
-
${
|
|
14
|
-
${
|
|
12
|
+
${p} login
|
|
13
|
+
${p} project [name or id]
|
|
14
|
+
${p} test [options]
|
|
15
|
+
${p} secret set <NAME>
|
|
15
16
|
|
|
16
17
|
Commands
|
|
17
18
|
login Sign in from a browser. Prints a code and a link, opens the browser
|
|
18
19
|
when it can, and saves a credential for one organization on this
|
|
19
|
-
machine.
|
|
20
|
+
machine. Then asks which SmoothDeploy project to use and saves it.
|
|
21
|
+
Over SSH, open the link on any device.
|
|
22
|
+
project Pick the SmoothDeploy project that test and secret set use, or
|
|
23
|
+
create one. Give a name or an id to pick without a prompt
|
|
20
24
|
logout Revoke the saved credential and delete it from this machine
|
|
21
|
-
whoami Print the signed-in user and
|
|
25
|
+
whoami Print the signed-in user, organization and project
|
|
22
26
|
test Run the Playwright project in this directory: pack it, upload it,
|
|
23
27
|
start a run, wait for the result and print a summary. Run it in the
|
|
24
28
|
directory that holds playwright.config.*
|
|
25
29
|
secret set <NAME> Save a secret. The value is encrypted on this machine before upload.
|
|
26
|
-
See ${
|
|
30
|
+
See ${p} secret --help
|
|
27
31
|
|
|
28
32
|
Runs receive the project's secrets automatically.
|
|
29
33
|
|
|
@@ -36,9 +40,11 @@ Options for test
|
|
|
36
40
|
|
|
37
41
|
Environment
|
|
38
42
|
SMOOTHDEPLOY_API_KEY API key with the Test Runs create and read scopes. When it is set,
|
|
39
|
-
it is used instead of the ${
|
|
40
|
-
SMOOTHDEPLOY_PROJECT_ID UUID of the SmoothDeploy project
|
|
41
|
-
|
|
43
|
+
it is used instead of the ${p} login credential
|
|
44
|
+
SMOOTHDEPLOY_PROJECT_ID UUID of the SmoothDeploy project. When it is set, it is used instead
|
|
45
|
+
of the project saved by ${p} login. Not needed when the API key
|
|
46
|
+
has the Projects read scope and can see one active project
|
|
47
|
+
SMOOTHDEPLOY_API_URL API base URL (default ${re})
|
|
42
48
|
SMOOTHDEPLOY_COMMIT_SHA, SMOOTHDEPLOY_BRANCH, SMOOTHDEPLOY_CI_URL
|
|
43
49
|
Override the detected commit, branch and CI job link
|
|
44
50
|
|
|
@@ -48,13 +54,13 @@ Exit codes
|
|
|
48
54
|
2 Could not run: usage, configuration, upload or API error, the run failed
|
|
49
55
|
before its tests, it was cancelled, the timeout passed or the connection was lost
|
|
50
56
|
130 Interrupted; the run continues
|
|
51
|
-
`,
|
|
52
|
-
${
|
|
57
|
+
`,te=`Usage
|
|
58
|
+
${p} secret set <NAME>
|
|
53
59
|
|
|
54
|
-
Save a secret for the runs of the
|
|
60
|
+
Save a secret for the runs of the selected SmoothDeploy project. If a secret
|
|
55
61
|
with this name exists, its value is replaced.
|
|
56
62
|
|
|
57
|
-
The value is encrypted on this machine before upload: ${
|
|
63
|
+
The value is encrypted on this machine before upload: ${p} fetches a public key
|
|
58
64
|
from SmoothDeploy, encrypts the value with it and sends only the ciphertext. The
|
|
59
65
|
encryption is bound to the secret name and the project.
|
|
60
66
|
|
|
@@ -64,30 +70,31 @@ projects need is set once per project.
|
|
|
64
70
|
|
|
65
71
|
The value is never read from a flag, an environment variable or a config file:
|
|
66
72
|
On a terminal type it at the hidden prompt
|
|
67
|
-
From a pipe ${
|
|
68
|
-
for example: ${
|
|
73
|
+
From a pipe ${p} reads all of stdin and drops one trailing newline,
|
|
74
|
+
for example: ${p} secret set DB_PASSWORD < password.txt
|
|
69
75
|
|
|
70
76
|
NAME has letters, digits and underscores only, at most 64 characters. Names the
|
|
71
77
|
runner relies on are reserved: PATH, HOME, CI, NODE_*, PLAYWRIGHT_*, LD_* and others.
|
|
72
78
|
|
|
73
79
|
Environment
|
|
74
|
-
SMOOTHDEPLOY_API_KEY API key with the Test Runs create scope, or sign in with ${
|
|
75
|
-
SMOOTHDEPLOY_PROJECT_ID UUID of the SmoothDeploy project
|
|
76
|
-
SMOOTHDEPLOY_API_URL API base URL (default ${
|
|
80
|
+
SMOOTHDEPLOY_API_KEY API key with the Test Runs create scope, or sign in with ${p} login
|
|
81
|
+
SMOOTHDEPLOY_PROJECT_ID UUID of the SmoothDeploy project, or pick one with ${p} project
|
|
82
|
+
SMOOTHDEPLOY_API_URL API base URL (default ${re})
|
|
77
83
|
|
|
78
84
|
Exit codes
|
|
79
85
|
0 The secret was saved
|
|
80
86
|
2 Nothing was saved
|
|
81
|
-
`,
|
|
82
|
-
${He.join(`
|
|
87
|
+
`,u=class extends Error{},O=e=>e<1024**2?`${Math.ceil(e/1024)} KB`:`${(e/1024**2).toFixed(1)} MB`,J=e=>new Promise(t=>setTimeout(t,e));function Mt(e){let t=/^(\d+(?:\.\d+)?)(s|m|h)?$/.exec(e.trim());if(!t)throw new u(`--timeout "${e}" is not a duration. Use for example 30m, 2h or 90s.`);let n=t[2]==="s"?1e3:t[2]==="h"?36e5:6e4;return Number(t[1])*n}var Ht=new Map([["invalid_api_key","Check SMOOTHDEPLOY_API_KEY: the key is wrong, deleted or expired."],["unauthorized",`Check SMOOTHDEPLOY_API_KEY, or run ${p} login again.`],["api_key_forbidden","This credential cannot do that."],["ip_not_allowed","The API key does not allow requests from this IP address. Edit its allowed IPs under Operations > API Keys."],["api_key_wrong_project","The API key is restricted to another project. Check SMOOTHDEPLOY_PROJECT_ID or use another key."],["project_not_found",`No project with this id exists in the organization. Check SMOOTHDEPLOY_PROJECT_ID, or run ${p} project.`],["LICENSE_REQUIRED","The organization has no active subscription. See Organization > Billing in the app."],["runner_size_unavailable","Try another --size."],["parallel_limit_exceeded","Pick a smaller --size or raise the organization's parallels."],["queue_full","Too many runs are waiting. Try again when some have started."],["too_many_requests","Too many runs were created in the last minutes. Wait a little and run again."],["test_run_not_found","The run is not in the selected project."],["run_already_started","The run was already started and continues."],["archive_missing","The uploaded archive did not arrive. Run again."]]);function K(e,t){if(e.code==="playwright_version_unsupported"){let r=e.details?.versions??[];return`${e.message}. Supported versions: ${r.join(", ")||"none listed"}. Install one of them, for example \`npm install -D @playwright/test@${r.at(-1)??"<version>"}\`, and commit the lockfile.`}if(e.code==="minutes_exhausted"||e.code==="payment_failed")return`${e.message} Nothing ran.`;if(e.code==="run_not_startable")return`${t} failed: the run is ${e.details?.status??"finished"} and can no longer be started. Run again.`;if(e.code==="archive_too_large")return`${t} failed: the archive is over the ${O(e.details?.max??ee)} limit.`;if(e.status===0)return`${t} failed: ${e.message}. Check your network and SMOOTHDEPLOY_API_URL.`;let n=Ht.get(e.code);return`${t} failed: ${e.message} (${e.code}, HTTP ${e.status}).${n?` ${n}`:""}`}async function _(e,t){try{return await t()}catch(n){throw n instanceof w?new u(K(n,e)):n}}async function Bt(e,t,n,r){let s=-1,o=i=>{let c=Math.floor(i/r*100);!e.live||c===s||(s=c,e.status(`Uploading ${c}% (${O(i)} of ${O(r)})`))};e.live||e.line(`Uploading ${O(r)}`);for(let i=1;;i++)try{await ce(t.uploadUrl,t.uploadHeaders,n,r,o),e.line(`Uploaded ${O(r)}`);return}catch(c){let a=c;if(a.code==="upload_expired")throw new u("Upload failed: the upload link expired (it is valid for 15 minutes). Run again.");if(!(a.status===0||a.status>=500)||i>=3)throw new u(`Upload failed: ${a.message}. Nothing ran. Check your network and run again.`);e.line(`Upload failed (${a.message}), retrying`),await J(1e3*i)}}var Yt=new Map([["created","Waiting to start"],["pending","Waiting for a free parallel"],["queued","Starting a runner"],["running","Running tests"]]);async function zt(e,t,n,r,s,o){let i=Date.now(),c="",a=0,l=()=>e.status(`${c} ${e.dim(Y(Date.now()-i))}`),f=e.live?setInterval(()=>c&&l(),1e3):void 0;try{for(;;){let d;try{d=await t.get("runs.get",{runId:n}),a=0}catch(g){let y=g;if(!(y instanceof w&&(y.status===0||y.status===429||y.status>=500)))throw g instanceof w?new u(K(y,"Reading the run")):g;if(a++,a>=Ne)throw new u(`Lost the connection to SmoothDeploy (${y.message}). The run continues: ${r}`);e.line(`Could not read the run (${y.message}), retrying`),await J(Math.min(o*2**(a-1),6e4));continue}if(d.terminal)return d;let m=Yt.get(d.status)??d.status;if(m!==c&&(c=m,e.live?l():e.line(`${Y(Date.now()-i)} ${c}`)),Date.now()+o>s)throw new u(`Stopped waiting after the --timeout. The run is still going: ${r}`);await J(o)}}finally{clearInterval(f),e.done()}}function ie(e){let t=e.SMOOTHDEPLOY_API_URL?.trim()||re;if(!URL.canParse(t))throw new u(`SMOOTHDEPLOY_API_URL "${t}" is not a URL.`);return new URL(t).origin}function ve(e){let t=M(e);if(!t)return null;R(t.token);let n=ie(e);if(t.apiUrl!==n)throw new u(`Signed in to ${t.apiUrl}, not ${n}. Run ${p} login again.`);return t}function xe(e,t){let n=e.SMOOTHDEPLOY_API_KEY?.trim();if(n)return R(n),{apiUrl:ie(e),apiKey:n,projectId:void 0};let r=ve(e);if(!r)throw new u(`Not signed in. Run ${p} login, or create an API key with the ${t} under Operations > API Keys in SmoothDeploy and set SMOOTHDEPLOY_API_KEY.`);return{apiUrl:r.apiUrl,apiKey:r.token,projectId:r.projectId}}async function Me(e,t){let{apiUrl:n,apiKey:r,projectId:s}=xe(e,t),o=e.SMOOTHDEPLOY_PROJECT_ID?.trim()||s;if(o&&!xt.test(o))throw new u(`SMOOTHDEPLOY_PROJECT_ID "${o}" is not a project UUID.`);if(!o){let i=$(n,r,void 0,b),c=await se(i).catch(a=>{if(a instanceof w&&a.status===403)return[];throw a});if(c.length!==1)throw new u(`No SmoothDeploy project is selected. Run ${p} project, or set SMOOTHDEPLOY_PROJECT_ID to the UUID of the project.`);o=c[0].id}return{projectId:o,client:$(n,r,o,b)}}var se=async e=>(await _("Reading the projects",()=>e.get("projects.list",{limit:"500"}))).filter(t=>t.status==="active");async function He(e,t,n){let r=await se(t);if(n){let i=r.filter(a=>a.id===n.toLowerCase()||a.name.toLowerCase()===n.toLowerCase());if(i.length===1)return i[0];let c=r.map(a=>a.name).join(", ")||"none";throw new u(i.length?`${i.length} projects are named "${n}". Pass the project id instead.`:`No active project "${n}". Projects: ${c}.`)}if(r.length===1)return r[0];let s=Dt({input:process.stdin})[Symbol.asyncIterator](),o=async i=>{process.stderr.write(i);let c=await s.next();return process.stdin.isTTY||process.stderr.write(`
|
|
88
|
+
`),c.done?null:String(c.value).trim()};try{let i=r.length+1;if(r.length){for(e.line("SmoothDeploy projects:"),r.forEach((l,f)=>e.line(` ${f+1}) ${l.name}`)),e.line(` ${i}) Create a new project`);;){let l=await o(`Project to use (1-${i}): `);if(!l)return null;if(i=Number(l),Number.isInteger(i)&&i>=1&&i<=r.length+1)break;e.error(`"${l}" is not a number from 1 to ${r.length+1}.`)}if(i<=r.length)return r[i-1]}else e.line("The organization has no active project.");let c=await o("Name for the new project (at most 32 characters): ");return c?{id:(await _("Creating the project",()=>t.post("projects.create",{name:c}))).id,name:c,status:"active"}:null}finally{await s.return?.(),process.stdin.pause()}}function Jt(e,t){if(e.SSH_CONNECTION||e.SSH_TTY||!process.stdout.isTTY)return!1;let[n,r]=process.platform==="darwin"?["open",[t]]:process.platform==="win32"?["rundll32",["url.dll,FileProtocolHandler",t]]:["xdg-open",[t]];try{let s=Pt(n,r,{stdio:"ignore",detached:!0,windowsHide:!0});return s.on("error",()=>{}),s.unref(),!0}catch{return!1}}async function Kt(e,t,n){let r=Number(n.SMOOTHDEPLOY_POLL_INTERVAL_MS)||t.interval*1e3,s=Date.now()+t.expiresIn*1e3,o=0;for(;;){if(await J(r),Date.now()>s)throw new u(`The code expired. Run ${p} login again.`);try{let i=await e.post("cli-sessions.token",{deviceCode:t.deviceCode});return R(i.token),i}catch(i){if(!(i instanceof w))throw i;if(i.code==="cli_login_pending")continue;if(i.code==="cli_login_slow_down"){r+=5e3;continue}if(i.code==="cli_login_denied")throw new u("The sign-in was denied in the browser. Nothing was saved.");if(i.code==="cli_login_expired")throw new u(`The code expired. Run ${p} login again.`);if(!(i.status===0||i.status===429||i.status>=500)||++o>=Ne)throw new u(K(i,"Signing in"))}}}async function Gt(e,t){let n=ie(t),r=$(n,void 0,void 0,b),s=Lt().replace(/[^\x20-\x7e]/g,"").trim().slice(0,64)||"unknown",o=await _("Starting the sign-in",()=>r.post("cli-sessions.start",{machineName:s}));R(o.deviceCode);let i=URL.canParse(o.verificationUriComplete)?new URL(o.verificationUriComplete):null;if(!i||!["https:","http:"].includes(i.protocol))throw new u("Starting the sign-in failed: the server sent no valid link.");e.line(`Code: ${o.userCode.replace(/^(.{4})(.+)$/,"$1-$2")}`),e.line(`Open ${i.href} and approve the sign-in for ${s}. Check that the page shows this code.`),Jt(t,i.href)&&e.line("Opened the browser."),e.line("Waiting for approval...");let c=await Kt(r,o,t),a=H(t,{apiUrl:n,token:c.token});e.line(`Signed in as ${c.email} to ${c.organization}. Saved the credential to ${a}.`);try{let l=await He(e,$(n,c.token,void 0,b));l&&H(t,{apiUrl:n,token:c.token,projectId:l.id}),e.line(l?`Using project ${l.name}. Change it with ${p} project.`:`No project selected. Run ${p} project to pick one.`)}catch(l){if(!(l instanceof u))throw l;e.error(`${l.message} You are signed in. Run ${p} project to pick a project.`)}return t.SMOOTHDEPLOY_API_KEY?.trim()&&e.line("SMOOTHDEPLOY_API_KEY is set and is used instead of this credential while it is set."),h.passed}async function Ft(e,t){let n=M(t);if(!n)return q(t),e.line("Not signed in."),h.passed;R(n.token);let r=$(n.apiUrl,n.token,void 0,b);try{await r.post("cli-sessions.logout",{})}catch(s){if(!(s instanceof w&&(s.status===401||s.status===404)))throw s instanceof w?new u(`${K(s,"Signing out")} The credential is kept in ${j(t)}.`):s}return q(t),e.line("Signed out. The credential is revoked and deleted from this machine."),h.passed}async function Wt(e,t){if(t.SMOOTHDEPLOY_API_KEY?.trim())return e.line("Using the API key in SMOOTHDEPLOY_API_KEY. An API key belongs to an organization, not to a user."),h.passed;let{apiUrl:n,apiKey:r}=xe(t,"Test Runs create and read scopes"),s=$(n,r,void 0,b),o=await _("Reading the sign-in",()=>s.get("cli-sessions.whoami",{}));e.line(`Signed in as ${o.email} to ${o.organization} on ${o.machineName}.`);let i=M(t)?.projectId;if(!i)return e.line(`No project selected. Run ${p} project to pick one.`),h.passed;let c=(await se(s)).find(a=>a.id===i);return e.line(c?`Project: ${c.name}`:`The selected project ${i} is not an active project. Run ${p} project to pick another.`),h.passed}async function Vt(e,t,n){let r=ve(t);if(!r)throw new u(`Not signed in. Run ${p} login. ${p} project changes the project saved by ${p} login.`);let s=await He(e,$(r.apiUrl,r.token,void 0,b),n);if(!s)throw new u("No project selected. Nothing changed.");return H(t,{...r,projectId:s.id}),e.line(`Using project ${s.name}.`),t.SMOOTHDEPLOY_PROJECT_ID?.trim()&&e.line("SMOOTHDEPLOY_PROJECT_ID is set and is used instead of this project while it is set."),h.passed}var Ae={login:Gt,logout:Ft,whoami:Wt};async function qt(e,t,n,r){let s=t.size??"micro";if(!(s in Le))throw new u(`--size "${s}" is not a runner size. Use one of ${Object.keys(Le).join(", ")}.`);let o=Date.now()+Mt(t.timeout??"2h"),{projectId:i,client:c}=await Me(n,"Test Runs create and read scopes"),a=process.cwd();if(!vt.some(T=>Ct(a).includes(T)))throw new u(`No playwright.config.{ts,js,mts,mjs,cts,cjs} in ${a}. Run ${p} test in the directory of your Playwright project.`);let l=pe(n,a,T=>e.error(T)),f=bt("git",["rev-parse","--show-toplevel"],{cwd:a,encoding:"utf8",windowsHide:!0}).stdout?.trim(),d=f?P.resolve(f):P.parse(a).root,m=await he(a,d),g=P.relative(m.dir,a).split(P.sep).join("/")||".",y=me(m.name,await jt(P.join(m.dir,m.name),"utf8"),g),N=kt(P.join(At(),`${p}-`));r.tmp=N;try{let T=await Ie(m.dir);for(let x of T.skippedLinks)e.error(`Skipped ${x}: the link points outside ${m.dir}`);let oe=P.join(N,"project.tgz"),U=await Pe(T.entries,oe),Be=g==="."?"":`, tests in ${g}`;if(e.line(`Packed ${T.entries.length} files from ${m.dir} (${O(U)}${Be}), Playwright ${y}`),U>ee){let x=be(T.entries),Ye=[...x.dirs,...x.files].map(([ze,Je])=>` ${O(Je).padStart(9)} ${ze}`);throw new u(`The archive is ${O(U)}, over the 250 MB limit. Biggest directories and files:
|
|
89
|
+
${Ye.join(`
|
|
83
90
|
`)}
|
|
84
|
-
Add large files that the tests do not need to .gitignore and run again.`)}let
|
|
91
|
+
Add large files that the tests do not need to .gitignore and run again.`)}let ae=[l.branch,l.commitSha?.slice(0,7),l.provider].filter(Boolean).join(" \xB7 ");ae&&e.line(e.dim(ae));let v=await _("Creating the run",()=>c.post("runs.create",{projectId:i,playwrightVersion:y,size:s,archiveBytes:U,directory:g==="."?void 0:g,commitSha:l.commitSha,branch:l.branch,ciUrl:l.ciUrl})),G=await _("Reading the run",()=>c.get("runs.get",{runId:v.id}));r.url=G.url,e.line(`Run ${G.url}`),await Bt(e,v,oe,U),await _("Starting the run",()=>c.post("runs.start",{runId:v.id})),r.started=!0;let C=await zt(e,c,v.id,G.url,o,Number(n.SMOOTHDEPLOY_POLL_INTERVAL_MS)||1e4);return je(e,C),t.json&&e.json(C),C.status==="completed"?h.passed:C.status==="failed"&&!C.failureReason?h.failed:h.error}finally{De(N,{recursive:!0,force:!0})}}async function Xt(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf8").replace(/\r?\n$/,"")}function Qt(e){let t=process.stdin;return new Promise((n,r)=>{let s="",o=c=>{t.off("data",i),t.setRawMode(!1),t.pause(),process.stderr.write(`
|
|
85
92
|
`),c?r(c):n(s)},i=c=>{for(let a of c){if(a==="\r"||a===`
|
|
86
|
-
`||a==="")return o();if(a==="")return o(new
|
|
93
|
+
`||a==="")return o();if(a==="")return o(new u("Stopped. Nothing was saved."));a==="\x7F"||a==="\b"?s=[...s].slice(0,-1).join(""):s+=a}};process.stderr.write(e),t.setEncoding("utf8"),t.setRawMode(!0),t.on("data",i),t.resume()})}async function Zt(e,t,n){if(!/^[A-Za-z0-9_]{1,64}$/.test(t))throw new u(`"${t}" is not a secret name. Use letters, digits and underscores, at most 64 characters.`);let{projectId:r,client:s}=await Me(n,"Test Runs create scope"),{publicKey:o}=await _("Reading the encryption key",()=>s.get("secrets.public-key",{})),i=process.stdin.isTTY?await Qt(`Value for ${t} (hidden): `):await Xt();if(!i)throw new u("The value is empty. Nothing was saved.");R(i);let c=await _("Saving the secret",()=>s.post("secrets.set",{projectId:r,name:t,...Ue(o,r,t,i)}));return e.line(`${c.created?"Created":"Updated"} secret ${t}. It was encrypted on this machine before upload. Runs of this project receive it automatically.`),h.passed}async function en(e,t){let n,r;try{({values:n,positionals:r}=Nt({args:e,allowPositionals:!0,options:{size:{type:"string"},timeout:{type:"string"},json:{type:"boolean"},help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"}}}))}catch(f){return process.stderr.write(`${f.message}
|
|
87
94
|
|
|
88
|
-
${
|
|
89
|
-
`:s),
|
|
95
|
+
${z}`),h.error}let s=r[0]==="secret"?te:z;if(n.version||n.help)return process.stdout.write(n.version?`${ne.version}
|
|
96
|
+
`:s),h.passed;let o=r.length===1&&Object.hasOwn(Ae,r[0])?Ae[r[0]]:null,i=r[0]==="project"&&r.length<=2;if(o||i){let f=B(!1,t);try{return await(o?o(f,t):Vt(f,t,r[1]))}catch(d){return f.error(d instanceof u?d.message:`Unexpected error: ${d.message}`),h.error}}if(r[0]==="secret"){if(r[1]!=="set"||r.length!==3)return process.stderr.write(r.length>1?`Unknown command "${r.join(" ")}".
|
|
90
97
|
|
|
91
|
-
${
|
|
98
|
+
${te}`:te),h.error;let f=B(!1,t);try{return await Zt(f,r[2],t)}catch(d){return f.error(d instanceof u?d.message:`Unexpected error: ${d.message}`),h.error}}if(r.length!==1||r[0]!=="test")return process.stderr.write(r.length?`Unknown command "${r.join(" ")}".
|
|
92
99
|
|
|
93
|
-
${
|
|
100
|
+
${z}`:z),h.error;let c=B(!!n.json,t),a={},l=()=>{a.tmp&&De(a.tmp,{recursive:!0,force:!0}),c.done(),a.url?a.started?c.error(`Stopped waiting. The run continues: ${a.url}`):c.error(`Stopped. The run was not started: ${a.url}`):c.error("Stopped."),process.exit(h.interrupted)};process.once("SIGINT",l),process.once("SIGTERM",l);try{return await qt(c,n,t,a)}catch(f){return f instanceof u||f instanceof S?c.error(f.message):c.error(`Unexpected error: ${f.message}`),h.error}}process.exitCode=await en(process.argv.slice(2),process.env);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smoothdeploy/mainsail",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.4",
|
|
4
4
|
"description": "Run your Playwright tests on SmoothDeploy remote runners, from a terminal or CI",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"homepage": "https://smoothdeploy.com",
|