Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove dist task #146

Merged
merged 2 commits into from
Apr 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
37 changes: 0 additions & 37 deletions src/dist.task.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/docs/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 32 additions & 2 deletions src/project/dist.task.ts
Original file line number Diff line number Diff line change
@@ -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);