From a8fcfb8e678b53a3d3b7dec60f6341d4b380d8ea Mon Sep 17 00:00:00 2001 From: Mario Lubenka Date: Fri, 13 Mar 2020 15:09:54 +0100 Subject: [PATCH] refactor: move source files to dist/ folder BREAKING CHANGE: JavaScript files moved from project root into dist/ folder. If you are defining a relative root path via --root option please prepend a ../ to it. --- cli.js => dist/cli.js | 0 index.js => dist/index.js | 2 +- package.json | 6 +++--- sonar-project.properties | 1 + test/index.js | 10 +++++----- 5 files changed, 10 insertions(+), 9 deletions(-) rename cli.js => dist/cli.js (100%) rename index.js => dist/index.js (98%) diff --git a/cli.js b/dist/cli.js similarity index 100% rename from cli.js rename to dist/cli.js diff --git a/index.js b/dist/index.js similarity index 98% rename from index.js rename to dist/index.js index 370d808..fac84ae 100644 --- a/index.js +++ b/dist/index.js @@ -5,7 +5,7 @@ const path = require('path'); const colors = require('colors/safe'); const fs = require('fs'); const argv = require('yargs').argv; -let rootPath = path.join('..', '..', '..'); +let rootPath = path.join('..', '..', '..', '..'); if (argv.hasOwnProperty('root')) { rootPath = argv.root; } diff --git a/package.json b/package.json index a3f8f1a..2dd1bb1 100644 --- a/package.json +++ b/package.json @@ -2,12 +2,12 @@ "name": "@saithodev/ts-appversion", "version": "1.3.0", "description": "Reads the version from your packages.json and saves it in a .ts file you can include into your application.", - "main": "index.js", + "main": "dist/index.js", "bin": { - "ts-appversion": "cli.js" + "ts-appversion": "dist/cli.js" }, "scripts": { - "start": "node index.js", + "start": "node dist/index.js", "test": "nyc --reporter=text --reporter=lcov mocha", "snyk-protect": "snyk protect", "prepare": "npm run snyk-protect", diff --git a/sonar-project.properties b/sonar-project.properties index 2255d21..779d997 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -10,6 +10,7 @@ sonar.links.ci=https://travis-ci.com/saitho/ng-appversion sonar.links.scm=https://github.com/saitho/ng-appversion sonar.links.issue=https://github.com/saitho/ng-appversion/issues +sonar.sources=dist sonar.tests=test sonar.javascript.lcov.reportPaths=coverage/lcov.info \ No newline at end of file diff --git a/test/index.js b/test/index.js index cc8aeee..aa0a2fc 100644 --- a/test/index.js +++ b/test/index.js @@ -22,7 +22,7 @@ before(function() { describe('appversion', function() { it('should skip when no package.json is found.', function(done) { - exec('node index.js --root=' + repoDir + ' --file=version-test.ts', (err, stdout, stderr) => { + exec('node dist/index.js --root=' + repoDir + ' --file=version-test.ts', (err, stdout, stderr) => { if (err) { done('Test failed: Could not execute command.'); return; @@ -39,7 +39,7 @@ describe('appversion', function() { it('should succeed with default settings and without a Git repository', function(done) { fs.mkdirSync(path.join(repoDir, 'src'), {recursive: true}); fs.writeFileSync(path.join(repoDir, 'package.json'), '{"version": "1.0.0"}'); - exec('node index.js --root=' + repoDir, (err, stdout, stderr) => { + exec('node dist/index.js --root=' + repoDir, (err, stdout, stderr) => { if (err) { done('Test failed: Could not execute command.'); return; @@ -65,7 +65,7 @@ describe('appversion', function() { repo.init(); fs.mkdirSync(path.join(repoDir, 'src')); fs.writeFileSync(path.join(repoDir, 'package.json'), '{"version": "1.0.0"}'); - exec('node index.js --root=' + repoDir, (err, stdout, stderr) => { + exec('node dist/index.js --root=' + repoDir, (err, stdout, stderr) => { if (err) { done('Test failed: Could not execute command.'); return; @@ -92,7 +92,7 @@ describe('appversion', function() { it('should succeed with different file output', function(done) { repo.init(); fs.writeFileSync(path.join(repoDir, 'package.json'), '{"version": "1.0.0"}'); - exec('node index.js --root=' + repoDir + ' --file=version-test.ts', (err, stdout, stderr) => { + exec('node dist/index.js --root=' + repoDir + ' --file=version-test.ts', (err, stdout, stderr) => { if (err) { done('Test failed: Could not execute command.'); return; @@ -121,7 +121,7 @@ describe('appversion', function() { fs.mkdirSync(applicationDir); fs.mkdirSync(path.join(applicationDir, 'src')); fs.writeFileSync(path.join(applicationDir, 'package.json'), '{"version": "1.0.0"}'); - exec('node index.js --root=' + applicationDir + ' --git=..', (err, stdout, stderr) => { + exec('node dist/index.js --root=' + applicationDir + ' --git=..', (err, stdout, stderr) => { if (err) { done('Test failed: Could not execute command.'); return;