diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c38b57a..65d389d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build +name: Build & Publish on: push: @@ -9,12 +9,11 @@ on: jobs: build: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Use Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: '19' @@ -27,5 +26,7 @@ jobs: - name: Run compile script run: node scripts/compile.js - - name: Push to NPM - run: npm publish --dry-run \ No newline at end of file + - name: Publish to NPM + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }} \ No newline at end of file diff --git a/index.js b/index.js index 01c8ee9..bf5917f 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,18 @@ +const fs = require('fs'); + function getExtensionPath () { return __dirname + '/compiled.js'; } +let script = null; +function getInjectableScript() { + if (script === null) { + script = fs.readFileSync(getExtensionPath(), 'utf-8'); + } + return script; +} + module.exports = { - getExtensionPath + getExtensionPath, + getInjectableScript, } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 4a15b78..0663a02 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "cookies_modal_v2", - "version": "1.0.0", + "name": "idcac-playwright", + "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "cookies_modal_v2", - "version": "1.0.0", + "name": "idcac-playwright", + "version": "0.1.0", "license": "ISC", "devDependencies": { "@babel/generator": "^7.21.9", diff --git a/package.json b/package.json index e4e10f4..438e41c 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,17 @@ { "name": "idcac-playwright", - "version": "1.0.0", - "description": "", + "version": "0.1.0", + "description": "I Don't Care About Cookies for Playwright/Puppeteer", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, - "keywords": [], + "repository": { + "type": "git", + "url": "https://github.com/apify/idcac" + }, + "homepage": "https://github.com/apify/idcac", + "keywords": ["playwright", "puppeteer", "cookies"], "author": "", "license": "ISC", "devDependencies": { diff --git a/scripts/compile.js b/scripts/compile.js index 104fad6..3be5c17 100644 --- a/scripts/compile.js +++ b/scripts/compile.js @@ -40,16 +40,16 @@ class AST { (async () => { const sink = fs.createWriteStream(__dirname + '/../compiled.js', { flags: 'w' }); - + + sink.write('try {\n'); const rules = fs.readFileSync(__dirname + '/../extension/data/rules.js', 'utf-8'); const rulesUpdated = new AST(rules, { sourceType: 'module' }) - .makeVariableDeclarationsConst() + .makeVariableDeclarationsConst() // make all `var` declarations `const`, so they are automatically dropped as soon as the script ends. .dropSymbol('block_urls') .generate(); - - sink.write('try {\n'); sink.write(rulesUpdated); + sink.write('\n'); sink.write('const files = {\n');