cli: added initial build-cache command

This commit is contained in:
Patrik Oldsberg
2020-03-26 14:57:54 +01:00
parent 26266cb2f6
commit 555db720ae
2 changed files with 40 additions and 0 deletions
@@ -0,0 +1,22 @@
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* The build-cache command is used to make builds a no-op if there are no changes to the package.
* It supports both local development where the output directory remains intact, as well as CI
* where the output directory is stored in a separate cache dir.
*/
export default async () => {};
+18
View File
@@ -19,6 +19,7 @@ import chalk from 'chalk';
import fs from 'fs';
import createPluginCommand from './commands/create-plugin/createPlugin';
import watch from './commands/watch-deps';
import buildCache from './commands/build-cache';
import lintCommand from './commands/lint';
import testCommand from './commands/testCommand';
import appBuild from './commands/app/build';
@@ -76,6 +77,23 @@ const main = (argv: string[]) => {
.description('Watch all dependencies while running another command')
.action(actionHandler(watch));
program
.command('build-cache')
.description('Wrap build command with a cache')
.option(
'--input <dirs>',
'List of input directories that invalidate the cache [.]',
(value, acc) => acc.concat(value),
[],
)
.option('--output <dir>', 'Output directory to cache', 'dist')
.option(
'--cache-dir <dir>',
'Cache dir',
'<repoRoot>/node_modules/.cache/backstage-builds',
)
.action(actionHandler(buildCache));
program.on('command:*', () => {
console.log();
console.log(