Skip to content

Commit

Permalink
Merge pull request #9 from CloudCannon/feat/more-build-suggestion-fields
Browse files Browse the repository at this point in the history
Add suggestion fields for preserved paths and environments
  • Loading branch information
rphillips-cc authored Aug 27, 2024
2 parents 8fd405d + 54338fa commit 81ed8d0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/ssgs/hugo.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ export default class Hugo extends Ssg {
attribution: 'most common for Hugo sites',
});

commands.environment['HUGO_CACHEDIR'] = {
value: '/usr/local/__site/src/.hugo_cache/',
attribution: 'recommended for Hugo sites',
};

commands.preserved.push({
value: '.hugo_cache/,resources/',
attribution: 'recommended for speeding up Hugo builds',
});

return commands;
}
}
5 changes: 5 additions & 0 deletions src/ssgs/jekyll.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ export default class Jekyll extends Ssg {
attribution: 'most common for Jekyll sites',
});

commands.environment['JEKYLL_ENV'] = {
value: 'production',
attribution: 'recommended for hosted Jekyll sites',
};

return commands;
}
}
13 changes: 12 additions & 1 deletion src/ssgs/ssg.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,13 @@ export default class Ssg {
*/
async generateBuildCommands(filePaths, options) {
/** @type {import('../types').BuildCommands} */
const commands = { install: [], build: [], output: [] };
const commands = {
install: [],
build: [],
output: [],
preserved: [],
environment: {},
};

const packageJsonPath = joinPaths([options.source, 'package.json']);
if (filePaths.includes(packageJsonPath)) {
Expand All @@ -392,6 +398,11 @@ export default class Ssg {
attribution: 'because of your `package.json` file',
});

commands.preserved.push({
value: 'node_modules/',
attribution: 'because of your `package.json` file',
});

try {
const raw = options.readFile ? await options.readFile(packageJsonPath) : undefined;
const parsed = raw ? JSON.parse(raw) : undefined;
Expand Down
2 changes: 2 additions & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ export interface BuildCommands {
install: BuildCommandSuggestion[];
build: BuildCommandSuggestion[];
output: BuildCommandSuggestion[];
environment: Record<string, BuildCommandSuggestion>;
preserved: BuildCommandSuggestion[];
}

0 comments on commit 81ed8d0

Please sign in to comment.