@keinar/aac-cli 1.1.1 → 1.1.2

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.
Files changed (2) hide show
  1. package/dist/index.cjs +16 -10
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -1,15 +1,16 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var N=Object.create;var b=Object.defineProperty;var Y=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var G=(t,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of j(n))!_.call(t,i)&&i!==o&&b(t,i,{get:()=>n[i],enumerable:!(r=Y(n,i))||r.enumerable});return t};var f=(t,n,o)=>(o=t!=null?N(S(t)):{},G(n||!t||!t.__esModule?b(o,"default",{value:t,enumerable:!0}):o,t));var T=require("commander"),s=f(require("@clack/prompts"),1),y=f(require("picocolors"),1);var g=require("fs/promises"),D=require("path"),c=f(require("@clack/prompts"),1),p=f(require("picocolors"),1);var w="1.50.0";function O(t){return`FROM mcr.microsoft.com/playwright:v${t}-jammy
2
+ "use strict";var I=Object.create;var b=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var U=(t,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Y(n))!j.call(t,i)&&i!==o&&b(t,i,{get:()=>n[i],enumerable:!(r=S(n,i))||r.enumerable});return t};var g=(t,n,o)=>(o=t!=null?I(_(t)):{},U(n||!t||!t.__esModule?b(o,"default",{value:t,enumerable:!0}):o,t));var N=require("commander"),s=g(require("@clack/prompts"),1),y=g(require("picocolors"),1);var f=require("fs/promises"),R=require("path"),c=g(require("@clack/prompts"),1),p=g(require("picocolors"),1);var w="1.50.0";function E(t){return`FROM mcr.microsoft.com/playwright:v${t}-jammy
3
3
 
4
4
  WORKDIR /app
5
5
 
6
6
  COPY package*.json ./
7
7
  RUN npm ci
8
+ RUN npm install -g allure-commandline
8
9
 
9
10
  COPY . .
10
11
 
11
12
  RUN chmod +x /app/entrypoint.sh
12
- `}var E=`#!/bin/sh
13
+ `}var O=`#!/bin/sh
13
14
 
14
15
  FOLDER=$1
15
16
 
@@ -18,13 +19,18 @@ if [ -f .env ]; then
18
19
  rm .env
19
20
  fi
20
21
 
22
+ echo "Running against BASE_URL: $BASE_URL"
23
+
21
24
  if [ -z "$FOLDER" ] || [ "$FOLDER" = "all" ]; then
22
25
  echo "Running ALL tests..."
23
- exec npx playwright test
26
+ npx playwright test
24
27
  else
25
28
  echo "Running tests in folder: $FOLDER"
26
- exec npx playwright test "$FOLDER"
29
+ npx playwright test "$FOLDER"
27
30
  fi
31
+
32
+ echo "Generating Allure Report..."
33
+ npx allure generate allure-results --clean -o allure-report
28
34
  `,P=`FROM python:3.11-slim
29
35
 
30
36
  WORKDIR /app
@@ -56,9 +62,9 @@ fi
56
62
  node_modules
57
63
  __pycache__
58
64
  .venv
59
- `;async function H(t){try{let n=await(0,g.readFile)((0,D.join)(t,"package.json"),"utf-8"),o=JSON.parse(n),r=o.devDependencies?.["@playwright/test"]??o.dependencies?.["@playwright/test"];return r?r.replace(/^[^\d]*/,"")||w:w}catch{return w}}async function U(t,n){let o=t==="playwright",r;if(o){let i=await H(n);c.log.info(`Detected Playwright version: ${p.default.cyan("v"+i)}`),r=O(i)}else r=P;return[{name:".dockerignore",content:$,mode:420},{name:"entrypoint.sh",content:o?E:C,mode:493},{name:"Dockerfile",content:r,mode:420}]}async function q(t){try{return await(0,g.stat)(t),!0}catch{return!1}}function B(t){return t.replace(/\r\n/g,`
60
- `)}async function F(t,n){let o=await U(t,n),r=new Set;for(let a of o){let d=(0,D.join)(n,a.name);if(await q(d)){let m=await c.confirm({message:`File ${p.default.yellow(a.name)} already exists. Overwrite?`});c.isCancel(m)&&(c.cancel("Operation cancelled."),process.exit(0)),m||r.add(a.name)}}if(r.size===o.length){c.log.warn("All files were skipped. No changes were made.");return}let i=[];for(let a of o){if(r.has(a.name))continue;let d=(0,D.join)(n,a.name),m=B(a.content);await(0,g.writeFile)(d,m,{mode:a.mode}),i.push(a.name)}for(let a of i)c.log.success(`Created ${p.default.green(a)}`);c.note([`${p.default.bold("1.")} docker build -t your-username/my-automation-tests:latest .`,`${p.default.bold("2.")} docker push your-username/my-automation-tests:latest`,`${p.default.bold("3.")} Enter this image name in the AAC Dashboard.`].join(`
61
- `),`${p.default.green("\u2705")} Next steps to connect your project to the AAC`)}var R=require("child_process"),v=require("fs/promises"),A=require("path"),e=f(require("@clack/prompts"),1),l=f(require("picocolors"),1);async function W(t){try{let n=await(0,v.readFile)((0,A.join)(t,"package.json"),"utf-8"),o=JSON.parse(n);return o.name?o.name.replace(/^@[^/]+\//,""):null}catch{return null}}async function L(t){let n=await e.confirm({message:"Do you have a Docker Hub account?"});if(e.isCancel(n)){e.cancel("Deployment cancelled.");return}n||(e.note(`Create a free account at ${l.default.cyan("https://hub.docker.com")}
62
- Press Enter when you're ready to continue.`,l.default.yellow("Docker Hub Account Required")),await e.text({message:"Press Enter to continue...",defaultValue:"",placeholder:""}));let o=await e.text({message:"What is your Docker Hub username?",validate:u=>{if(!u.trim())return"Username is required."}});if(e.isCancel(o)){e.cancel("Deployment cancelled.");return}let r=await W(t),i;if(r){let u=await e.confirm({message:`Detected project name "${l.default.cyan(r)}". Use this for the image?`});if(e.isCancel(u)){e.cancel("Deployment cancelled.");return}if(u)i=r;else{let h=await e.text({message:"Enter the image name:",validate:I=>{if(!I.trim())return"Image name is required."}});if(e.isCancel(h)){e.cancel("Deployment cancelled.");return}i=h.trim()}}else{let u=await e.text({message:"Enter the image name:",validate:h=>{if(!h.trim())return"Image name is required."}});if(e.isCancel(u)){e.cancel("Deployment cancelled.");return}i=u.trim()}let a=`${o.trim()}/${i}:latest`,d=await e.confirm({message:"I need to log you into Docker. Send a login request?"});if(e.isCancel(d)){e.cancel("Deployment cancelled.");return}if(d){e.log.step("Opening Docker login...");try{(0,R.execSync)("docker login",{stdio:"inherit",cwd:t}),e.log.success("Docker login successful.")}catch{e.log.error("Docker login failed. Please try again manually.");return}}let m=await e.confirm({message:`Build multi-platform image ${l.default.cyan(a)} and push to Docker Hub?`});if(e.isCancel(m)||!m){e.log.warn("Build skipped."),e.note([`${l.default.bold("1.")} docker buildx create --name aac-builder --use`,`${l.default.bold("2.")} docker buildx build --platform linux/amd64,linux/arm64 -t ${a} --push .`].join(`
63
- `),"You can build manually later");return}let k=e.spinner();try{k.start("Setting up Docker Buildx builder..."),(0,R.execSync)("docker buildx create --name aac-builder --use",{stdio:"pipe",cwd:t}),k.stop("Buildx builder ready.")}catch{k.stop("Using existing Buildx builder.")}e.log.step(`Building & pushing ${l.default.cyan(a)}...`);try{(0,R.execSync)(`docker buildx build --platform linux/amd64,linux/arm64 -t ${a} --push .`,{stdio:"inherit",cwd:t}),e.log.success(`Image ${l.default.green(a)} pushed successfully!`),e.note(`Go to the ${l.default.bold("AAC Dashboard")} and enter:
64
- ${l.default.cyan(a)}`,l.default.green("\u2705 Deployment Complete"))}catch{e.log.error("Docker build failed. Check the output above for details.")}}var x=new T.Command;x.name("aac-cli").description("Agnostic Automation Center CLI \u2014 Prepare any test automation repo for the AAC platform").version("1.1.0");x.command("init").description("Generate AAC integration files and optionally build & push your Docker image").action(async()=>{s.intro(y.default.bgCyan(y.default.black(" AAC CLI ")));let t=await s.select({message:"Select your automation project framework:",options:[{value:"playwright",label:"Playwright (TypeScript/Node.js)"},{value:"pytest",label:"Pytest (Python)"}]});s.isCancel(t)&&(s.cancel("Operation cancelled."),process.exit(0));let n=s.spinner();n.start("Generating AAC integration files..."),await new Promise(i=>setTimeout(i,300)),n.stop("Files ready.");let o=process.cwd();await F(t,o);let r=await s.confirm({message:"Do you want to build and push the image to Docker Hub right now?"});s.isCancel(r)&&(s.cancel("Operation cancelled."),process.exit(0)),r&&await L(o),s.outro(y.default.green("Done!")+" "+y.default.dim("Run `aac-cli init` again anytime."))});x.parse();
65
+ `;async function G(t){try{let n=await(0,f.readFile)((0,R.join)(t,"package.json"),"utf-8"),o=JSON.parse(n),r=o.devDependencies?.["@playwright/test"]??o.dependencies?.["@playwright/test"];return r?r.replace(/^[^\d]*/,"")||w:w}catch{return w}}async function B(t,n){let o=t==="playwright",r;if(o){let i=await G(n);c.log.info(`Detected Playwright version: ${p.default.cyan("v"+i)}`),r=E(i)}else r=P;return[{name:".dockerignore",content:$,mode:420},{name:"entrypoint.sh",content:o?O:C,mode:493},{name:"Dockerfile",content:r,mode:420}]}async function H(t){try{return await(0,f.stat)(t),!0}catch{return!1}}function q(t){return t.replace(/\r\n/g,`
66
+ `)}async function A(t,n){let o=await B(t,n),r=new Set;for(let a of o){let d=(0,R.join)(n,a.name);if(await H(d)){let m=await c.confirm({message:`File ${p.default.yellow(a.name)} already exists. Overwrite?`});c.isCancel(m)&&(c.cancel("Operation cancelled."),process.exit(0)),m||r.add(a.name)}}if(r.size===o.length){c.log.warn("All files were skipped. No changes were made.");return}let i=[];for(let a of o){if(r.has(a.name))continue;let d=(0,R.join)(n,a.name),m=q(a.content);await(0,f.writeFile)(d,m,{mode:a.mode}),i.push(a.name)}for(let a of i)c.log.success(`Created ${p.default.green(a)}`);c.note([`${p.default.bold("1.")} docker build -t your-username/my-automation-tests:latest .`,`${p.default.bold("2.")} docker push your-username/my-automation-tests:latest`,`${p.default.bold("3.")} Enter this image name in the AAC Dashboard.`].join(`
67
+ `),`${p.default.green("\u2705")} Next steps to connect your project to the AAC`)}var D=require("child_process"),F=require("fs/promises"),v=require("path"),e=g(require("@clack/prompts"),1),l=g(require("picocolors"),1);async function W(t){try{let n=await(0,F.readFile)((0,v.join)(t,"package.json"),"utf-8"),o=JSON.parse(n);return o.name?o.name.replace(/^@[^/]+\//,""):null}catch{return null}}async function L(t){let n=await e.confirm({message:"Do you have a Docker Hub account?"});if(e.isCancel(n)){e.cancel("Deployment cancelled.");return}n||(e.note(`Create a free account at ${l.default.cyan("https://hub.docker.com")}
68
+ Press Enter when you're ready to continue.`,l.default.yellow("Docker Hub Account Required")),await e.text({message:"Press Enter to continue...",defaultValue:"",placeholder:""}));let o=await e.text({message:"What is your Docker Hub username?",validate:u=>{if(!u.trim())return"Username is required."}});if(e.isCancel(o)){e.cancel("Deployment cancelled.");return}let r=await W(t),i;if(r){let u=await e.confirm({message:`Detected project name "${l.default.cyan(r)}". Use this for the image?`});if(e.isCancel(u)){e.cancel("Deployment cancelled.");return}if(u)i=r;else{let h=await e.text({message:"Enter the image name:",validate:T=>{if(!T.trim())return"Image name is required."}});if(e.isCancel(h)){e.cancel("Deployment cancelled.");return}i=h.trim()}}else{let u=await e.text({message:"Enter the image name:",validate:h=>{if(!h.trim())return"Image name is required."}});if(e.isCancel(u)){e.cancel("Deployment cancelled.");return}i=u.trim()}let a=`${o.trim()}/${i}:latest`,d=await e.confirm({message:"I need to log you into Docker. Send a login request?"});if(e.isCancel(d)){e.cancel("Deployment cancelled.");return}if(d){e.log.step("Opening Docker login...");try{(0,D.execSync)("docker login",{stdio:"inherit",cwd:t}),e.log.success("Docker login successful.")}catch{e.log.error("Docker login failed. Please try again manually.");return}}let m=await e.confirm({message:`Build multi-platform image ${l.default.cyan(a)} and push to Docker Hub?`});if(e.isCancel(m)||!m){e.log.warn("Build skipped."),e.note([`${l.default.bold("1.")} docker buildx create --name aac-builder --use`,`${l.default.bold("2.")} docker buildx build --platform linux/amd64,linux/arm64 -t ${a} --push .`].join(`
69
+ `),"You can build manually later");return}let k=e.spinner();try{k.start("Setting up Docker Buildx builder..."),(0,D.execSync)("docker buildx create --name aac-builder --use",{stdio:"pipe",cwd:t}),k.stop("Buildx builder ready.")}catch{k.stop("Using existing Buildx builder.")}e.log.step(`Building & pushing ${l.default.cyan(a)}...`);try{(0,D.execSync)(`docker buildx build --platform linux/amd64,linux/arm64 -t ${a} --push .`,{stdio:"inherit",cwd:t}),e.log.success(`Image ${l.default.green(a)} pushed successfully!`),e.note(`Go to the ${l.default.bold("AAC Dashboard")} and enter:
70
+ ${l.default.cyan(a)}`,l.default.green("\u2705 Deployment Complete"))}catch{e.log.error("Docker build failed. Check the output above for details.")}}var x=new N.Command;x.name("aac-cli").description("Agnostic Automation Center CLI \u2014 Prepare any test automation repo for the AAC platform").version("1.1.0");x.command("init").description("Generate AAC integration files and optionally build & push your Docker image").action(async()=>{s.intro(y.default.bgCyan(y.default.black(" AAC CLI ")));let t=await s.select({message:"Select your automation project framework:",options:[{value:"playwright",label:"Playwright (TypeScript/Node.js)"},{value:"pytest",label:"Pytest (Python)"}]});s.isCancel(t)&&(s.cancel("Operation cancelled."),process.exit(0));let n=s.spinner();n.start("Generating AAC integration files..."),await new Promise(i=>setTimeout(i,300)),n.stop("Files ready.");let o=process.cwd();await A(t,o);let r=await s.confirm({message:"Do you want to build and push the image to Docker Hub right now?"});s.isCancel(r)&&(s.cancel("Operation cancelled."),process.exit(0)),r&&await L(o),s.outro(y.default.green("Done!")+" "+y.default.dim("Run `aac-cli init` again anytime."))});x.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keinar/aac-cli",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Agnostic Automation Center CLI — Prepare any test automation repo for the AAC platform",
5
5
  "author": "keinar",
6
6
  "license": "MIT",