From ee83b9eb58e5eeea6c77449ede3e6abf44967b31 Mon Sep 17 00:00:00 2001 From: Nicolas Martel Date: Wed, 9 Aug 2023 09:53:55 -0700 Subject: [PATCH 1/3] fix: archive whitelist to support custom name --- lib/generate.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generate.js b/lib/generate.js index 72f0939..2a9c398 100644 --- a/lib/generate.js +++ b/lib/generate.js @@ -59,7 +59,7 @@ module.exports = async (root, pkg, release, customName) => { const serviceFile = generateServiceFile(root, customPackage); const specFile = generateSpecFile(specsDirectory, customPackage, release); - const archiveWhitelist = getArchiveWhitelist(pkg); + const archiveWhitelist = getArchiveWhitelist(customPackage); await archiver.compress(root, sourcesArchive, archiveWhitelist); From 525acb70387e22b7908e4c957d3e5a22d3f770aa Mon Sep 17 00:00:00 2001 From: Nicolas Martel Date: Wed, 9 Aug 2023 10:21:40 -0700 Subject: [PATCH 2/3] test: amend cases with white list and custom name --- test/generate.js | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/test/generate.js b/test/generate.js index 3d3f5d3..c35e6bb 100644 --- a/test/generate.js +++ b/test/generate.js @@ -103,6 +103,15 @@ describe('generate', () => { ); }); + it('creates the spec file with a custom name if specified with white list', async () => { + await generate('/path/to/project', pkgWithWhitelist, 1, 'penguin'); + sandbox.assert.calledWith( + fs.writeFileSync, + '/path/to/project/SPECS/penguin.spec', + sandbox.match('%define name penguin') + ); + }); + it('creates the sources archive with a custom name if specified', async () => { await generate('/path/to/project', pkg, null, 'penguin'); sandbox.assert.calledWith( @@ -112,7 +121,21 @@ describe('generate', () => { { files: undefined, main: 'index.js', - service: 'my-cool-api.service' + service: 'penguin.service' + } + ); + }); + + it('creates the sources archive with a custom name if specified with white list', async () => { + await generate('/path/to/project', pkgWithWhitelist, null, 'penguin'); + sandbox.assert.calledWith( + archiver.compress, + '/path/to/project', + '/path/to/project/SOURCES/penguin.tar.gz', + { + files: undefined, + main: 'index.js', + service: 'penguin.service' } ); }); @@ -144,6 +167,15 @@ describe('generate', () => { ); }); + it('creates the service file with a custom name if specified with white list', async () => { + await generate('/path/to/project', pkgWithWhitelist, 1, 'penguin'); + sandbox.assert.calledWith( + fs.writeFileSync, + '/path/to/project/penguin.service', + sandbox.match('SyslogIdentifier=penguin') + ); + }); + it('creates the sources archive with a custom name if specified', async () => { await generate('/path/to/project', pkg, null, 'penguin'); sandbox.assert.calledWith( @@ -153,6 +185,15 @@ describe('generate', () => { ); }); + it('creates the sources archive with a custom name if specified with white list', async () => { + await generate('/path/to/project', pkgWithWhitelist, null, 'penguin'); + sandbox.assert.calledWith( + archiver.compress, + '/path/to/project', + '/path/to/project/SOURCES/penguin.tar.gz' + ); + }); + it('returns an array of files created', async () => { const filesExpected = ['SPECS/my-cool-api.spec', 'SOURCES/my-cool-api.tar.gz', 'my-cool-api.service']; const files = await generate('/path/to/project', pkg, null, null); From 61cf1d45209f694819392ffc8169208e21b31b9c Mon Sep 17 00:00:00 2001 From: Nicolas Martel Date: Wed, 9 Aug 2023 10:28:19 -0700 Subject: [PATCH 3/3] test: amend cases with white list and custom name --- test/generate.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/generate.js b/test/generate.js index c35e6bb..7e9c6ad 100644 --- a/test/generate.js +++ b/test/generate.js @@ -133,8 +133,12 @@ describe('generate', () => { '/path/to/project', '/path/to/project/SOURCES/penguin.tar.gz', { - files: undefined, - main: 'index.js', + main: 'server.js', + files: [ + 'lib', + 'routes', + 'index.js' + ], service: 'penguin.service' } );