diff --git a/changelog.md b/changelog.md index c2913df115..7d38dd5c8f 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,8 @@ ([#145](https://github.com/feltcoop/gro/pull/145)) - add task `gro server` to support the default API server use case in SvelteKit ([#145](https://github.com/feltcoop/gro/pull/145)) +- remove the `gro dist` task; it's now part of `gro build` + ([#146](https://github.com/feltcoop/gro/pull/146)) ## 0.11.3 diff --git a/src/dist.task.ts b/src/dist.task.ts deleted file mode 100644 index 7fded49a13..0000000000 --- a/src/dist.task.ts +++ /dev/null @@ -1,37 +0,0 @@ -import type {Task} from './task/task.js'; -import {copy} from './fs/nodeFs.js'; -import {paths, toBuildOutPath} from './paths.js'; -import {isTestBuildFile, isTestBuildArtifact} from './fs/testModule.js'; -import {printPath} from './utils/print.js'; -import {clean} from './project/clean.js'; -import {loadGroConfig} from './config/config.js'; -import {configureLogLevel} from './utils/log.js'; -import {printBuildConfig} from './config/buildConfig.js'; - -export const isDistFile = (path: string): boolean => - !isTestBuildFile(path) && !isTestBuildArtifact(path); - -export const task: Task = { - description: 'create the distribution', - dev: false, - run: async ({dev, log}) => { - await clean({dist: true}, log); - - // This reads the `dist` flag on the build configs to help construct the final dist directory. - // See the docs at `./docs/config.md`. - const config = await loadGroConfig(dev); - configureLogLevel(config.logLevel); - const buildConfigsForDist = config.builds.filter((b) => b.dist); - await Promise.all( - buildConfigsForDist.map((buildConfig) => { - const buildOutDir = toBuildOutPath(dev, buildConfig.name); - const distOutDir = - buildConfigsForDist.length === 1 - ? paths.dist - : `${paths.dist}${printBuildConfig(buildConfig)}`; - log.info(`copying ${printPath(buildOutDir)} to ${printPath(distOutDir)}`); - return copy(buildOutDir, distOutDir, {filter: (id) => isDistFile(id)}); - }), - ); - }, -}; diff --git a/src/docs/tasks.md b/src/docs/tasks.md index 2a803d5015..c983b6565c 100644 --- a/src/docs/tasks.md +++ b/src/docs/tasks.md @@ -12,7 +12,6 @@ What is a task? See [`src/tasks/README.md`](../task). - [clean](../clean.task.ts) - remove temporary dev and build files - [deploy](../deploy.task.ts) - deploy to gh-pages - [dev](../dev.task.ts) - start dev server -- [dist](../dist.task.ts) - create the distribution - [format](../format.task.ts) - format source files - [gen](../gen.task.ts) - run code generation scripts - [project/build](../project/build.task.ts) - build, create, and link the distribution diff --git a/src/project/dist.task.ts b/src/project/dist.task.ts index 7ff81d225a..f9b0e60ad6 100644 --- a/src/project/dist.task.ts +++ b/src/project/dist.task.ts @@ -1,9 +1,39 @@ import type {Task} from '../task/task.js'; +import {copy} from '../fs/nodeFs.js'; +import {paths, toBuildOutPath} from '../paths.js'; +import {isTestBuildFile, isTestBuildArtifact} from '../fs/testModule.js'; +import {printPath} from '../utils/print.js'; +import {clean} from './clean.js'; +import {loadGroConfig} from '../config/config.js'; +import {configureLogLevel} from '../utils/log.js'; +import {printBuildConfig} from '../config/buildConfig.js'; export const task: Task = { description: 'create and link the distribution', - run: async ({invokeTask}) => { - await invokeTask('dist'); + dev: false, + run: async ({invokeTask, dev, log}) => { + await clean({dist: true}, log); + + // This reads the `dist` flag on the build configs to help construct the final dist directory. + // See the docs at `./docs/config.md`. + const config = await loadGroConfig(dev); + configureLogLevel(config.logLevel); + const buildConfigsForDist = config.builds.filter((b) => b.dist); + await Promise.all( + buildConfigsForDist.map((buildConfig) => { + const buildOutDir = toBuildOutPath(dev, buildConfig.name); + const distOutDir = + buildConfigsForDist.length === 1 + ? paths.dist + : `${paths.dist}${printBuildConfig(buildConfig)}`; + log.info(`copying ${printPath(buildOutDir)} to ${printPath(distOutDir)}`); + return copy(buildOutDir, distOutDir, {filter: (id) => isDistFile(id)}); + }), + ); + await invokeTask('project/link'); }, }; + +export const isDistFile = (path: string): boolean => + !isTestBuildFile(path) && !isTestBuildArtifact(path);