aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-05-25 20:48:19 +0530
committerLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-05-25 20:53:22 +0530
commitf850c0dde3d666cba66eac2f49600a8a0b5a27b7 (patch)
treeb6aafbe9c5fb377f669ba940e6e065896396ae77 /scripts
parentAdded harvest recipe (diff)
downloadferdium-recipes-f850c0dde3d666cba66eac2f49600a8a0b5a27b7.tar.gz
ferdium-recipes-f850c0dde3d666cba66eac2f49600a8a0b5a27b7.tar.zst
ferdium-recipes-f850c0dde3d666cba66eac2f49600a8a0b5a27b7.zip
Bypass hygiene check for git dirty state if running within a Docker container where the git repo is not present.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/package.js41
1 files changed, 24 insertions, 17 deletions
diff --git a/scripts/package.js b/scripts/package.js
index dca3de6..a6c23ca 100644
--- a/scripts/package.js
+++ b/scripts/package.js
@@ -49,6 +49,10 @@ const compress = (src, dest) => new Promise((resolve, reject) => {
49 await fs.remove(allJson); 49 await fs.remove(allJson);
50 50
51 const git = await simpleGit(repoRoot); 51 const git = await simpleGit(repoRoot);
52 const isGitRepo = await git.checkIsRepo();
53 if (!isGitRepo) {
54 console.debug("NOT A git repo: will bypass dirty state checks");
55 }
52 56
53 const availableRecipes = fs.readdirSync(recipesFolder, { withFileTypes: true }) 57 const availableRecipes = fs.readdirSync(recipesFolder, { withFileTypes: true })
54 .filter(dir => dir.isDirectory()) 58 .filter(dir => dir.isDirectory())
@@ -125,24 +129,27 @@ const compress = (src, dest) => new Promise((resolve, reject) => {
125 configErrors.push("The recipe's package.json contains no 'config' object. This field should contain a configuration for your service."); 129 configErrors.push("The recipe's package.json contains no 'config' object. This field should contain a configuration for your service.");
126 } 130 }
127 131
128 const relativeRepoSrc = path.relative(repoRoot, recipeSrc); 132 if (isGitRepo) {
129 // Check for changes in recipe's directory, and if changes are present, then the changes should contain a version bump 133 const relativeRepoSrc = path.relative(repoRoot, recipeSrc);
130 await git.diffSummary(relativeRepoSrc, (err, result) => { 134
131 if (err) { 135 // Check for changes in recipe's directory, and if changes are present, then the changes should contain a version bump
132 configErrors.push(`Got the following error while checking for git changes: ${err}`); 136 await git.diffSummary(relativeRepoSrc, (err, result) => {
133 } else if (result && (result.changed !== 0 || result.insertions !== 0 || result.deletions !== 0)) { 137 if (err) {
134 const pkgJsonRelative = path.relative(repoRoot, packageJson); 138 configErrors.push(`Got the following error while checking for git changes: ${err}`);
135 if (!result.files.find(({file}) => file === pkgJsonRelative)) { 139 } else if (result && (result.changed !== 0 || result.insertions !== 0 || result.deletions !== 0)) {
136 configErrors.push(`Found changes in '${relativeRepoSrc}' without the corresponding version bump in '${pkgJsonRelative}'`); 140 const pkgJsonRelative = path.relative(repoRoot, packageJson);
137 } else { 141 if (!result.files.find(({file}) => file === pkgJsonRelative)) {
138 git.diff(pkgJsonRelative, (_diffErr, diffResult) => { 142 configErrors.push(`Found changes in '${relativeRepoSrc}' without the corresponding version bump in '${pkgJsonRelative}'`);
139 if (diffResult && !pkgVersionChangedMatcher.test(diffResult)) { 143 } else {
140 configErrors.push(`Found changes in '${relativeRepoSrc}' without the corresponding version bump in '${pkgJsonRelative}' (found other changes though)`); 144 git.diff(pkgJsonRelative, (_diffErr, diffResult) => {
141 } 145 if (diffResult && !pkgVersionChangedMatcher.test(diffResult)) {
142 }); 146 configErrors.push(`Found changes in '${relativeRepoSrc}' without the corresponding version bump in '${pkgJsonRelative}' (found other changes though)`);
147 }
148 });
149 }
143 } 150 }
144 } 151 });
145 }); 152 };
146 153
147 if (configErrors.length > 0) { 154 if (configErrors.length > 0) {
148 console.log(`⚠️ Couldn't package "${recipe}": There were errors in the recipe's package.json: 155 console.log(`⚠️ Couldn't package "${recipe}": There were errors in the recipe's package.json: