@wopee-io/wopee.pw 4.23.1 → 4.24.0

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.
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.logVersionMetadata = void 0;
4
4
  const child_process_1 = require("child_process");
5
5
  const logVersionMetadata = () => {
6
- let version = "4.23.1"
7
- let hash = "a6738eeb512dd35e98c310822f57e54b9f44d388"
6
+ let version = "4.24.0"
7
+ let hash = "de4b6222b53dd923cf8f50c12731a5cba8d98667"
8
8
  if (version === '__LOCAL__') {
9
9
  version = process.env.npm_package_version || '__LOCAL__';
10
10
  }
@@ -4,26 +4,36 @@ declare const ExtendIntegrationScenarioPayloadSchema: z.ZodObject<{
4
4
  projectUuid: z.ZodString;
5
5
  scenarioUuid: z.ZodString;
6
6
  pwSteps: z.ZodString;
7
+ githubRunId: z.ZodOptional<z.ZodString>;
8
+ githubRunAttempt: z.ZodOptional<z.ZodNumber>;
7
9
  }, "strip", z.ZodTypeAny, {
8
10
  projectUuid?: string;
9
11
  scenarioUuid?: string;
10
12
  pwSteps?: string;
13
+ githubRunId?: string;
14
+ githubRunAttempt?: number;
11
15
  }, {
12
16
  projectUuid?: string;
13
17
  scenarioUuid?: string;
14
18
  pwSteps?: string;
19
+ githubRunId?: string;
20
+ githubRunAttempt?: number;
15
21
  }>;
16
22
  }, "strip", z.ZodTypeAny, {
17
23
  input?: {
18
24
  projectUuid?: string;
19
25
  scenarioUuid?: string;
20
26
  pwSteps?: string;
27
+ githubRunId?: string;
28
+ githubRunAttempt?: number;
21
29
  };
22
30
  }, {
23
31
  input?: {
24
32
  projectUuid?: string;
25
33
  scenarioUuid?: string;
26
34
  pwSteps?: string;
35
+ githubRunId?: string;
36
+ githubRunAttempt?: number;
27
37
  };
28
38
  }>;
29
39
  type ExtendIntegrationScenarioPayload = z.infer<typeof ExtendIntegrationScenarioPayloadSchema>;
@@ -11,6 +11,8 @@ const ExtendIntegrationScenarioPayloadSchema = zod_1.z.object({
11
11
  required_error: 'Scenario UUID is required, please propagate "testInfo" as second argument in "test.beforeEach" hook and pass it to "wopee.startScenario("scenarioTitle", testInfo)" method as second argument if you want to use features of Wopee reporter',
12
12
  }),
13
13
  pwSteps: zod_1.z.string(),
14
+ githubRunId: zod_1.z.string().optional(),
15
+ githubRunAttempt: zod_1.z.number().optional(),
14
16
  }),
15
17
  });
16
18
  exports.ExtendIntegrationScenarioPayloadSchema = ExtendIntegrationScenarioPayloadSchema;
@@ -1 +1 @@
1
- {"version":3,"file":"wopeeReporter.interface.js","sourceRoot":"","sources":["../../../../lib/tools/wopee-reporter/types/wopeeReporter.interface.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,MAAM,sCAAsC,GAAG,OAAC,CAAC,MAAM,CAAC;IACtD,KAAK,EAAE,OAAC,CAAC,MAAM,CAAC;QACd,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC;YACpB,cAAc,EAAE,0BAA0B;SAC3C,CAAC;QACF,YAAY,EAAE,OAAC,CAAC,MAAM,CAAC;YACrB,cAAc,EACZ,6OAA6O;SAChP,CAAC;QACF,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;KACpB,CAAC;CACH,CAAC,CAAC;AAIM,wFAAsC","sourcesContent":["import { z } from 'zod';\n\nconst ExtendIntegrationScenarioPayloadSchema = z.object({\n input: z.object({\n projectUuid: z.string({\n required_error: 'Project UUID is required',\n }),\n scenarioUuid: z.string({\n required_error:\n 'Scenario UUID is required, please propagate \"testInfo\" as second argument in \"test.beforeEach\" hook and pass it to \"wopee.startScenario(\"scenarioTitle\", testInfo)\" method as second argument if you want to use features of Wopee reporter',\n }),\n pwSteps: z.string(),\n }),\n});\n\ntype ExtendIntegrationScenarioPayload = z.infer<typeof ExtendIntegrationScenarioPayloadSchema>;\n\nexport { ExtendIntegrationScenarioPayloadSchema, ExtendIntegrationScenarioPayload };\n"]}
1
+ {"version":3,"file":"wopeeReporter.interface.js","sourceRoot":"","sources":["../../../../lib/tools/wopee-reporter/types/wopeeReporter.interface.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,MAAM,sCAAsC,GAAG,OAAC,CAAC,MAAM,CAAC;IACtD,KAAK,EAAE,OAAC,CAAC,MAAM,CAAC;QACd,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC;YACpB,cAAc,EAAE,0BAA0B;SAC3C,CAAC;QACF,YAAY,EAAE,OAAC,CAAC,MAAM,CAAC;YACrB,cAAc,EACZ,6OAA6O;SAChP,CAAC;QACF,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;QAGnB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAClC,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KACxC,CAAC;CACH,CAAC,CAAC;AAIM,wFAAsC","sourcesContent":["import { z } from 'zod';\n\nconst ExtendIntegrationScenarioPayloadSchema = z.object({\n input: z.object({\n projectUuid: z.string({\n required_error: 'Project UUID is required',\n }),\n scenarioUuid: z.string({\n required_error:\n 'Scenario UUID is required, please propagate \"testInfo\" as second argument in \"test.beforeEach\" hook and pass it to \"wopee.startScenario(\"scenarioTitle\", testInfo)\" method as second argument if you want to use features of Wopee reporter',\n }),\n pwSteps: z.string(),\n // Set automatically inside GitHub Actions; lets the backend link this\n // execution to its workflow run so the raw Actions log can be fetched later.\n githubRunId: z.string().optional(),\n githubRunAttempt: z.number().optional(),\n }),\n});\n\ntype ExtendIntegrationScenarioPayload = z.infer<typeof ExtendIntegrationScenarioPayloadSchema>;\n\nexport { ExtendIntegrationScenarioPayloadSchema, ExtendIntegrationScenarioPayload };\n"]}
@@ -86,11 +86,11 @@ class WopeeReporter {
86
86
  extendIntegrationScenario(input: $input)
87
87
  }`;
88
88
  const extendIntegrationScenarioPayload = {
89
- input: {
90
- projectUuid: WOPEE_PROJECT_UUID,
91
- scenarioUuid: wopeeScenarioUuid,
92
- pwSteps: JSON.stringify(steps, helpers_1.replacer),
93
- },
89
+ input: Object.assign(Object.assign({ projectUuid: WOPEE_PROJECT_UUID, scenarioUuid: wopeeScenarioUuid, pwSteps: JSON.stringify(steps, helpers_1.replacer) }, (process.env.GITHUB_RUN_ID && {
90
+ githubRunId: process.env.GITHUB_RUN_ID,
91
+ })), (process.env.GITHUB_RUN_ATTEMPT && {
92
+ githubRunAttempt: Number(process.env.GITHUB_RUN_ATTEMPT),
93
+ })),
94
94
  };
95
95
  const variables = wopeeReporter_interface_js_1.ExtendIntegrationScenarioPayloadSchema.parse(extendIntegrationScenarioPayload);
96
96
  const uploadPromise = new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
@@ -1 +1 @@
1
- {"version":3,"file":"wopeeReporter.js","sourceRoot":"","sources":["../../../lib/tools/wopee-reporter/wopeeReporter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAsF;AACtF,+DAA6D;AAC7D,mFAG4C;AAE5C,kDAA0B;AAC1B,yBAAuB;AACvB,sDAAyB;AAEzB,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAEzE,MAAa,aAAa;IAGxB;QACE,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAED,SAAS,CAAC,IAAc,EAAE,MAAkB;;QAC1C,MAAM,SAAS,GAAG,IAAA,2BAAiB,GAAE,CAAC;QAEtC,MAAM,iBAAiB,GAAG,MAAA,MAAA,MAAM,CAAC,WAAW;aACzC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,IAAI,MAAK,qBAAqB,CAAC,0CAC7C,IAAI,0CAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAE5B,MAAM,UAAU,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CA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gBACD,MAAM,CAAC,IAAI,KAAK,CAAC,qEAAqE,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,EAAE,CAAC,CAAC,CAAC;YAC3G,CAAC;QACH,CAAC,CAAA,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACvC,CAAC;IAEK,MAAM;;YACV,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAChC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,CAAC,WAAW,CAAC,MAAM,4BAA4B,CAAC,CAAC;gBAC9E,IAAI,CAAC;oBACH,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;oBACpC,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;gBACzD,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;gBACxD,CAAC;wBAAS,CAAC;oBACT,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;KAAA;IAED,aAAa;QACX,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAlID,sCAkIC","sourcesContent":["import { generateTestRunId, parseError, parseNestedSteps, replacer } from './helpers';\nimport { buildAxiosConfig } from './helpers/axios-config.js';\nimport {\n ExtendIntegrationScenarioPayload,\n ExtendIntegrationScenarioPayloadSchema,\n} from './types/wopeeReporter.interface.js';\nimport type { Reporter, TestCase, TestResult } from '@playwright/test/reporter';\nimport axios from 'axios';\nimport 'dotenv/config';\nimport fs from 'node:fs';\n\nconst { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID } = process.env;\n\nexport class WopeeReporter implements Reporter {\n private uploadQueue: Promise<any>[];\n\n constructor() {\n this.uploadQueue = [];\n }\n\n onTestEnd(test: TestCase, result: TestResult) {\n const testRunId = generateTestRunId();\n\n const wopeeScenarioUuid = result.attachments\n .find((a) => a?.name === 'wopee-scenario-uuid')\n ?.body?.toString('utf-8');\n\n const failedStep = [...result.steps].reverse().find((step) => step.error);\n\n const createStepId = (step: any) => `${step.title}-${step.category}-${step.startTime}`;\n const failedStepId = failedStep ? createStepId(failedStep) : null;\n\n let screenshotBase64: string | null = null;\n let videoBase64: string | null = null;\n\n for (const attachment of result.attachments) {\n if (attachment.name === 'screenshot' && attachment.contentType === 'image/png') {\n const filePath = attachment.path;\n if (filePath) {\n try {\n const imageBuffer = fs.readFileSync(filePath);\n screenshotBase64 = imageBuffer.toString('base64');\n } catch (error) {\n console.error('Error reading screenshot:', error);\n }\n }\n }\n\n if (\n attachment.name === 'video' &&\n (attachment.contentType === 'video/webm' ||\n attachment.contentType === 'video/mp4' ||\n attachment.contentType === 'video/avi')\n ) {\n const filePath = attachment.path;\n if (filePath) {\n try {\n const videoBuffer = fs.readFileSync(filePath);\n videoBase64 = videoBuffer.toString('base64');\n } catch (error) {\n console.error('Error reading video:', error);\n }\n }\n }\n }\n\n if (!wopeeScenarioUuid) {\n return console.error(\n '[WOPEE_REPORTER_ERROR]: Scenario UUID is required, please propagate \"testInfo\" as second argument in \"test.beforeEach\" hook and pass it to \"wopee.startScenario(\"scenarioTitle\", testInfo)\" method as second argument if you want to use features of Wopee reporter',\n );\n }\n\n const steps = result.steps.map((step, index) => ({\n testRunId,\n number: index + 1,\n testTitle: test.title,\n title: step.title,\n status: step.error ? 'failed' : 'passed',\n error: step.error ? parseError(step.error) : step.error,\n category: step.category,\n location: step.location,\n duration: step.duration,\n startTime: step.startTime,\n steps: parseNestedSteps(step.steps),\n screenshotBase64: createStepId(step) === failedStepId ? screenshotBase64 : null,\n videoBase64: createStepId(step) === failedStepId ? videoBase64 : null,\n }));\n\n const query = `\n mutation ExtendIntegrationScenario($input: ExtendIntegrationScenarioInput!) {\n extendIntegrationScenario(input: $input)\n }`;\n\n const extendIntegrationScenarioPayload: ExtendIntegrationScenarioPayload = {\n input: {\n projectUuid: WOPEE_PROJECT_UUID,\n scenarioUuid: wopeeScenarioUuid,\n pwSteps: JSON.stringify(steps, replacer),\n },\n };\n const variables = ExtendIntegrationScenarioPayloadSchema.parse(extendIntegrationScenarioPayload);\n\n const uploadPromise = new Promise(async (resolve, reject) => {\n try {\n const apiUrl = WOPEE_API_URL || 'https://api.wopee.io';\n const headers = {\n api_key: WOPEE_API_KEY,\n };\n const config = buildAxiosConfig(apiUrl, headers);\n const response = await axios.post(apiUrl, { query, variables }, config);\n resolve(response);\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const status = error.response?.status;\n const errorData = error.response?.data;\n const errorMessage = error.message;\n console.error('[WOPEE_REPORTER_ERROR]', errorMessage, errorData);\n reject(new Error(`API request failed with status code: ${status}.`));\n }\n reject(new Error(`[WOPEE_REPORTER_ERROR] Unexpected error occurred during API call: ${error?.message}`));\n }\n });\n\n this.uploadQueue.push(uploadPromise);\n }\n\n async onExit(): Promise<void> {\n if (this.uploadQueue.length > 0) {\n console.log(`Uploading ${this.uploadQueue.length} remaining test results...`);\n try {\n await Promise.all(this.uploadQueue);\n console.log('Successfully uploaded all test results.');\n } catch (error) {\n console.error('Error uploading test results:', error);\n } finally {\n this.uploadQueue = [];\n }\n }\n }\n\n printsToStdio(): boolean {\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"wopeeReporter.js","sourceRoot":"","sources":["../../../lib/tools/wopee-reporter/wopeeReporter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAsF;AACtF,+DAA6D;AAC7D,mFAG4C;AAE5C,kDAA0B;AAC1B,yBAAuB;AACvB,sDAAyB;AAEzB,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAEzE,MAAa,aAAa;IAGxB;QACE,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAED,SAAS,CAAC,IAAc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AA+B,EAAE,KAAK,CAAC,CAAC;gBACxD,CAAC;wBAAS,CAAC;oBACT,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;gBACxB,CAAC;YACH,CAAC;QACH,CAAC;KAAA;IAED,aAAa;QACX,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAxID,sCAwIC","sourcesContent":["import { generateTestRunId, parseError, parseNestedSteps, replacer } from './helpers';\nimport { buildAxiosConfig } from './helpers/axios-config.js';\nimport {\n ExtendIntegrationScenarioPayload,\n ExtendIntegrationScenarioPayloadSchema,\n} from './types/wopeeReporter.interface.js';\nimport type { Reporter, TestCase, TestResult } from '@playwright/test/reporter';\nimport axios from 'axios';\nimport 'dotenv/config';\nimport fs from 'node:fs';\n\nconst { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID } = process.env;\n\nexport class WopeeReporter implements Reporter {\n private uploadQueue: Promise<any>[];\n\n constructor() {\n this.uploadQueue = [];\n }\n\n onTestEnd(test: TestCase, result: TestResult) {\n const testRunId = generateTestRunId();\n\n const wopeeScenarioUuid = result.attachments\n .find((a) => a?.name === 'wopee-scenario-uuid')\n ?.body?.toString('utf-8');\n\n const failedStep = [...result.steps].reverse().find((step) => step.error);\n\n const createStepId = (step: any) => `${step.title}-${step.category}-${step.startTime}`;\n const failedStepId = failedStep ? createStepId(failedStep) : null;\n\n let screenshotBase64: string | null = null;\n let videoBase64: string | null = null;\n\n for (const attachment of result.attachments) {\n if (attachment.name === 'screenshot' && attachment.contentType === 'image/png') {\n const filePath = attachment.path;\n if (filePath) {\n try {\n const imageBuffer = fs.readFileSync(filePath);\n screenshotBase64 = imageBuffer.toString('base64');\n } catch (error) {\n console.error('Error reading screenshot:', error);\n }\n }\n }\n\n if (\n attachment.name === 'video' &&\n (attachment.contentType === 'video/webm' ||\n attachment.contentType === 'video/mp4' ||\n attachment.contentType === 'video/avi')\n ) {\n const filePath = attachment.path;\n if (filePath) {\n try {\n const videoBuffer = fs.readFileSync(filePath);\n videoBase64 = videoBuffer.toString('base64');\n } catch (error) {\n console.error('Error reading video:', error);\n }\n }\n }\n }\n\n if (!wopeeScenarioUuid) {\n return console.error(\n '[WOPEE_REPORTER_ERROR]: Scenario UUID is required, please propagate \"testInfo\" as second argument in \"test.beforeEach\" hook and pass it to \"wopee.startScenario(\"scenarioTitle\", testInfo)\" method as second argument if you want to use features of Wopee reporter',\n );\n }\n\n const steps = result.steps.map((step, index) => ({\n testRunId,\n number: index + 1,\n testTitle: test.title,\n title: step.title,\n status: step.error ? 'failed' : 'passed',\n error: step.error ? parseError(step.error) : step.error,\n category: step.category,\n location: step.location,\n duration: step.duration,\n startTime: step.startTime,\n steps: parseNestedSteps(step.steps),\n screenshotBase64: createStepId(step) === failedStepId ? screenshotBase64 : null,\n videoBase64: createStepId(step) === failedStepId ? videoBase64 : null,\n }));\n\n const query = `\n mutation ExtendIntegrationScenario($input: ExtendIntegrationScenarioInput!) {\n extendIntegrationScenario(input: $input)\n }`;\n\n const extendIntegrationScenarioPayload: ExtendIntegrationScenarioPayload = {\n input: {\n projectUuid: WOPEE_PROJECT_UUID,\n scenarioUuid: wopeeScenarioUuid,\n pwSteps: JSON.stringify(steps, replacer),\n ...(process.env.GITHUB_RUN_ID && {\n githubRunId: process.env.GITHUB_RUN_ID,\n }),\n ...(process.env.GITHUB_RUN_ATTEMPT && {\n githubRunAttempt: Number(process.env.GITHUB_RUN_ATTEMPT),\n }),\n },\n };\n const variables = ExtendIntegrationScenarioPayloadSchema.parse(extendIntegrationScenarioPayload);\n\n const uploadPromise = new Promise(async (resolve, reject) => {\n try {\n const apiUrl = WOPEE_API_URL || 'https://api.wopee.io';\n const headers = {\n api_key: WOPEE_API_KEY,\n };\n const config = buildAxiosConfig(apiUrl, headers);\n const response = await axios.post(apiUrl, { query, variables }, config);\n resolve(response);\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const status = error.response?.status;\n const errorData = error.response?.data;\n const errorMessage = error.message;\n console.error('[WOPEE_REPORTER_ERROR]', errorMessage, errorData);\n reject(new Error(`API request failed with status code: ${status}.`));\n }\n reject(new Error(`[WOPEE_REPORTER_ERROR] Unexpected error occurred during API call: ${error?.message}`));\n }\n });\n\n this.uploadQueue.push(uploadPromise);\n }\n\n async onExit(): Promise<void> {\n if (this.uploadQueue.length > 0) {\n console.log(`Uploading ${this.uploadQueue.length} remaining test results...`);\n try {\n await Promise.all(this.uploadQueue);\n console.log('Successfully uploaded all test results.');\n } catch (error) {\n console.error('Error uploading test results:', error);\n } finally {\n this.uploadQueue = [];\n }\n }\n }\n\n printsToStdio(): boolean {\n return false;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wopee-io/wopee.pw",
3
- "version": "4.23.1",
3
+ "version": "4.24.0",
4
4
  "description": "Playwright visual testing plugin by Wopee.io — catch visual regressions with AI-powered autonomous test maintenance",
5
5
  "keywords": [
6
6
  "playwright",
@@ -1,41 +0,0 @@
1
- name: Publish to NPM (public)
2
-
3
- on:
4
- workflow_dispatch:
5
-
6
- jobs:
7
- publish:
8
- runs-on: ubuntu-latest
9
- permissions:
10
- contents: read
11
- id-token: write
12
-
13
- steps:
14
- - name: Checkout
15
- uses: actions/checkout@v6
16
-
17
- - name: Setup Node.js
18
- uses: actions/setup-node@v6
19
- with:
20
- node-version: '22'
21
- registry-url: 'https://registry.npmjs.org'
22
-
23
- - name: Install dependencies
24
- uses: ./.github/actions/npm_clean_install
25
- with:
26
- npm-token: ${{ github.token }}
27
-
28
- - name: Build
29
- run: make build
30
-
31
- - name: Rename to public scope
32
- env:
33
- WOPEE_ORG_NAME: '@wopee-io'
34
- run: |
35
- node utils/changeOrganizationName.mjs
36
- node -e "const p=JSON.parse(require('fs').readFileSync('package.json','utf8')); delete p.publishConfig; require('fs').writeFileSync('package.json',JSON.stringify(p,null,2)+'\n')"
37
-
38
- - name: Publish to NPM
39
- env:
40
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
41
- run: npm publish --access public