From 67504787d29895a991cbf0dfb2edfdb801ae9f88 Mon Sep 17 00:00:00 2001 From: Akseli Palen Date: Mon, 8 Jan 2024 23:30:04 +0200 Subject: [PATCH 01/10] remove travis ci integration --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 96707cc..0000000 --- a/.travis.yml +++ /dev/null @@ -1,6 +0,0 @@ -language: node_js -node_js: - - 10 - - 12 - - 14 - - 16 From 2b543b1a4574bc7b6270c33fe4d2097e921a0cd5 Mon Sep 17 00:00:00 2001 From: Akseli Palen Date: Mon, 8 Jan 2024 23:30:31 +0200 Subject: [PATCH 02/10] sketch github actions workflow --- .github/workflows/test-genversion.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/test-genversion.yml diff --git a/.github/workflows/test-genversion.yml b/.github/workflows/test-genversion.yml new file mode 100644 index 0000000..dffe02b --- /dev/null +++ b/.github/workflows/test-genversion.yml @@ -0,0 +1,13 @@ +name: test-genversion +run-name: ${{ github.actor }} is testing genversion +on: [push] +jobs: + check-genversion-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: '14' + - run: npm install + - run: npm run test From 6fb5c9c2a9bc87f5b03c33e8b005fd71cee42dc4 Mon Sep 17 00:00:00 2001 From: Akseli Palen Date: Mon, 8 Jan 2024 23:58:20 +0200 Subject: [PATCH 03/10] use replace instead of replaceAll to support node<=14 --- lib/stringify.js | 6 ++-- test/cli.test.js | 60 +++++++++++++++++++++++++++++++++++++++ test/fixture/package.json | 3 ++ 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/lib/stringify.js b/lib/stringify.js index 15b4ded..d9e9214 100644 --- a/lib/stringify.js +++ b/lib/stringify.js @@ -31,15 +31,15 @@ const stringify = (value, options) => { // - unescaped double or single quotes ' if (quote === '\'') { // escape unescaped single quote - const escapedValue = value.replaceAll('\'', '\\\'') + const escapedValue = value.replace(/'/g, '\\\'') return quote + escapedValue + quote } else if (quote === '"') { // escape unescaped double quote - const escapedValue = value.replaceAll('"', '\\"') + const escapedValue = value.replace(/"/g, '\\"') return quote + escapedValue + quote } else if (quote === '`') { // escape unescaped backtick - const escapedValue = value.replaceAll('`', '\\`') + const escapedValue = value.replace(/`/g, '\\`') return quote + escapedValue + quote } // else diff --git a/test/cli.test.js b/test/cli.test.js index 9a73354..c048576 100644 --- a/test/cli.test.js +++ b/test/cli.test.js @@ -512,6 +512,66 @@ describe('genversion cli', () => { }) }) + it('should handle single quotes in properties', (done) => { + const clit = new CliTest() + const cmd = GENERATE_COMMAND + ' ' + + '--source ./test/fixture ' + + '--property author ' + P + clit.exec(cmd, (err, response) => { + if (err) { + return done(err) + } + + readTemp().should.equal(SIGNATURE + + 'module.exports = { ' + + 'name: \'Fo\\\'o "Bar" l`Baz\'' + + ' }\n' + ) + + return done() + }) + }) + + it('should handle double quotes in properties', (done) => { + const clit = new CliTest() + const cmd = GENERATE_COMMAND + ' ' + + '--source ./test/fixture ' + + '--property author --double ' + P + clit.exec(cmd, (err, response) => { + if (err) { + return done(err) + } + + readTemp().should.equal(SIGNATURE + + 'module.exports = { ' + + 'name: "Fo\'o \\"Bar\\" l`Baz"' + + ' }\n' + ) + + return done() + }) + }) + + it('should handle backticks in properties', (done) => { + const clit = new CliTest() + const cmd = GENERATE_COMMAND + ' ' + + '--source ./test/fixture ' + + '--property author -b ' + P + clit.exec(cmd, (err, response) => { + if (err) { + return done(err) + } + + readTemp().should.equal(SIGNATURE + + 'module.exports = { ' + + 'name: `Fo\'o "Bar" l\\`Baz`' + + ' }\n' + ) + + return done() + }) + }) + it('should not understand multiple property flags', (done) => { const clit = new CliTest() const cmd = GENERATE_COMMAND + ' --property name ' + diff --git a/test/fixture/package.json b/test/fixture/package.json index b857efd..42314cf 100644 --- a/test/fixture/package.json +++ b/test/fixture/package.json @@ -5,6 +5,9 @@ "keywords": ["foo", "bar"], "main": "index.js", "license": "MIT", + "author": { + "name": "Fo'o \"Bar\" l`Baz" + }, "dependencies": {}, "engines": { "node": ">=10.0.0", From 9b64d757034a0592a9938e4445a27a7cb2adb9f7 Mon Sep 17 00:00:00 2001 From: Akseli Palen Date: Tue, 9 Jan 2024 00:28:12 +0200 Subject: [PATCH 04/10] improve github actions workflow --- .github/workflows/genversion-ci.yml | 22 ++++++++++++++++++++++ .github/workflows/test-genversion.yml | 13 ------------- 2 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/genversion-ci.yml delete mode 100644 .github/workflows/test-genversion.yml diff --git a/.github/workflows/genversion-ci.yml b/.github/workflows/genversion-ci.yml new file mode 100644 index 0000000..decff1c --- /dev/null +++ b/.github/workflows/genversion-ci.yml @@ -0,0 +1,22 @@ +name: Genversion CI +run-name: ${{ github.actor }} is testing genversion + +on: [push] + +jobs: + test-genversion: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x, 16.x, 18.x] + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: npm install + - run: npm test diff --git a/.github/workflows/test-genversion.yml b/.github/workflows/test-genversion.yml deleted file mode 100644 index dffe02b..0000000 --- a/.github/workflows/test-genversion.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: test-genversion -run-name: ${{ github.actor }} is testing genversion -on: [push] -jobs: - check-genversion-version: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 - with: - node-version: '14' - - run: npm install - - run: npm run test From f7aa628885846b5963e0d415cb22462937c4dd29 Mon Sep 17 00:00:00 2001 From: Akseli Palen Date: Tue, 9 Jan 2024 00:34:33 +0200 Subject: [PATCH 05/10] try github actions without npm cache --- .github/workflows/genversion-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/genversion-ci.yml b/.github/workflows/genversion-ci.yml index decff1c..cc621d0 100644 --- a/.github/workflows/genversion-ci.yml +++ b/.github/workflows/genversion-ci.yml @@ -17,6 +17,5 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - cache: 'npm' - run: npm install - run: npm test From 7ee15c29f257b5a7412f7e94446b862f6a7e5d98 Mon Sep 17 00:00:00 2001 From: Akseli Palen Date: Tue, 9 Jan 2024 00:37:41 +0200 Subject: [PATCH 06/10] test on node v10 and v12 --- .github/workflows/genversion-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/genversion-ci.yml b/.github/workflows/genversion-ci.yml index cc621d0..d5d85da 100644 --- a/.github/workflows/genversion-ci.yml +++ b/.github/workflows/genversion-ci.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: - node-version: [14.x, 16.x, 18.x] + node-version: [10.x, 12.x, 14.x, 16.x, 18.x] steps: - uses: actions/checkout@v4 From 57de824e865d124fd394c5b01167b6e7047b3835 Mon Sep 17 00:00:00 2001 From: Akseli Palen Date: Tue, 9 Jan 2024 00:41:46 +0200 Subject: [PATCH 07/10] downgrade to standard v16 to support node v10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d0e492e..9234209 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "fs-extra": "^10.0.1", "mocha": "^10.2.0", "should": "^13.1.0", - "standard": "^17.1.0" + "standard": "^16.0.4" }, "engines": { "node": ">=10.0.0" From be79545a8c352bf627995d152644846471d1eb50 Mon Sep 17 00:00:00 2001 From: Akseli Palen Date: Tue, 9 Jan 2024 01:14:45 +0200 Subject: [PATCH 08/10] downgrade mocha@8 to support node v10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9234209..497a65b 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ }, "devDependencies": { "fs-extra": "^10.0.1", - "mocha": "^10.2.0", + "mocha": "^8.4.0", "should": "^13.1.0", "standard": "^16.0.4" }, From bd2ec88f0bf7592b25dea8b3eefbb3fd15ee7cc1 Mon Sep 17 00:00:00 2001 From: Akseli Palen Date: Tue, 9 Jan 2024 01:21:36 +0200 Subject: [PATCH 09/10] replace travis badge with github actions badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 238099c..861ab2c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ![Logo](doc/genversion-logo-halo.png?raw=true "Abracadabra...and behold!") -[![Travis build status](https://img.shields.io/travis/com/axelpale/genversion)](https://app.travis-ci.com/github/axelpale/genversion) +[![GitHub Actions workflow status](https://img.shields.io/github/actions/workflow/status/axelpale/genversion/genversion-ci.yml)](https://github.com/axelpale/genversion/actions/workflows/genversion-ci.yml) [![npm version](https://img.shields.io/npm/v/genversion?color=green)](https://www.npmjs.com/package/genversion) [![license](https://img.shields.io/npm/l/genversion)](#license) [![npm downloads](https://img.shields.io/npm/dm/genversion?color=green)](https://www.npmjs.com/package/genversion) From 46ec33722de7e14f991bba0669cbadb96a66ddcf Mon Sep 17 00:00:00 2001 From: Akseli Palen Date: Tue, 9 Jan 2024 01:23:04 +0200 Subject: [PATCH 10/10] npmignore github workflows --- .npmignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.npmignore b/.npmignore index f855a00..df1f66e 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,4 @@ +/.github /doc /test