diff --git a/packages/cli/src/commands/build-cache/index.ts b/packages/cli/src/commands/build-cache/index.ts new file mode 100644 index 0000000000..4cf3d8ef02 --- /dev/null +++ b/packages/cli/src/commands/build-cache/index.ts @@ -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 () => {}; diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 5f24190237..997c05c18c 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -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 ', + 'List of input directories that invalidate the cache [.]', + (value, acc) => acc.concat(value), + [], + ) + .option('--output ', 'Output directory to cache', 'dist') + .option( + '--cache-dir ', + 'Cache dir', + '/node_modules/.cache/backstage-builds', + ) + .action(actionHandler(buildCache)); + program.on('command:*', () => { console.log(); console.log(