Skip to content
This repository has been archived by the owner on Mar 10, 2023. It is now read-only.

Commit

Permalink
Move default pages back into the gatsby generator package
Browse files Browse the repository at this point in the history
  • Loading branch information
dpisani-atl committed Jan 14, 2020
1 parent 1b50cae commit b97ba11
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 43 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ scratchings.js
/packages/gatsby-generator/static/favicon.ico
/packages/gatsby-generator/typings

/packages/pipeline-stages/data

/packages/**/bundles
/packages/gatsby-generator/public
/packages/**/**/yarn.lock
Expand Down
4 changes: 3 additions & 1 deletion packages/file-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
],
"author": "Peter Yu",
"license": "MIT",
"files": ["dist"],
"files": [
"dist"
],
"peerDependencies": {
"react": "16.10.2",
"react-dom": "^16.8.4"
Expand Down
12 changes: 9 additions & 3 deletions packages/gatsby-generator/src/pipeline/buildPagesPipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ import {
import allPaths from './getAllPaths';

const buildPipeline = async (configPath?: string) => {
const { rootPath, wrappersPath, pagesPath, pkgRoot, config } = await allPaths(
configPath,
);
const {
rootPath,
wrappersPath,
pagesPath,
pkgRoot,
config,
defaultPagesPath,
} = await allPaths(configPath);

return scanMetadataStage({
rootPath,
Expand All @@ -23,6 +28,7 @@ const buildPipeline = async (configPath?: string) => {
generatePagesStage({
wrappersPath,
pagesPath,
defaultPagesPath,
packageRoot: pkgRoot,
...websiteInfo,
...config,
Expand Down
12 changes: 9 additions & 3 deletions packages/gatsby-generator/src/pipeline/buildPipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ const buildPipeline = async (
configPath?: string,
gatsbyOptions: string[] = [],
) => {
const { rootPath, wrappersPath, pagesPath, pkgRoot, config } = await allPaths(
configPath,
);
const {
rootPath,
wrappersPath,
pagesPath,
pkgRoot,
config,
defaultPagesPath,
} = await allPaths(configPath);

return scanMetadataStage({
rootPath,
Expand All @@ -29,6 +34,7 @@ const buildPipeline = async (
generatePagesStage({
wrappersPath,
pagesPath,
defaultPagesPath,
packageRoot: pkgRoot,
...websiteInfo,
...config,
Expand Down
12 changes: 9 additions & 3 deletions packages/gatsby-generator/src/pipeline/devPipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ import runGatsby from './stages/run-gatsby';
import allPaths from './getAllPaths';

const devPipeline = async (configPath?: string, gatsbyOptions?: string[]) => {
const { rootPath, wrappersPath, pagesPath, pkgRoot, config } = await allPaths(
configPath,
);
const {
rootPath,
wrappersPath,
pagesPath,
pkgRoot,
config,
defaultPagesPath,
} = await allPaths(configPath);

return scanMetadataStage({
rootPath,
Expand All @@ -23,6 +28,7 @@ const devPipeline = async (configPath?: string, gatsbyOptions?: string[]) => {
generatePagesStage({
wrappersPath,
pagesPath,
defaultPagesPath,
packageRoot: pkgRoot,
...websiteInfo,
...config,
Expand Down
2 changes: 2 additions & 0 deletions packages/gatsby-generator/src/pipeline/getAllPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ const getPathData = async (configPath?: string) => {
`./un-src/components/page-templates`,
);
const pagesPath = path.resolve(pkgRoot, `./pages`);
const defaultPagesPath = path.join(pkgRoot, 'default-pages');

return {
rootPath: cwd,
wrappersPath,
pagesPath,
pkgRoot,
config,
defaultPagesPath,
};
};
export default getPathData;
Empty file.
3 changes: 0 additions & 3 deletions packages/pipeline-stages/data/packages-data.json

This file was deleted.

5 changes: 0 additions & 5 deletions packages/pipeline-stages/data/pages-list.json

This file was deleted.

5 changes: 0 additions & 5 deletions packages/pipeline-stages/data/site-meta.json

This file was deleted.

3 changes: 2 additions & 1 deletion packages/pipeline-stages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
},
"peerDependencies": {},
"devDependencies": {
"jest-fixtures": "^0.6.0"
"jest-fixtures": "^0.6.0",
"mock-fs": "^4.10.1"
}
}

This file was deleted.

6 changes: 3 additions & 3 deletions packages/pipeline-stages/src/generate-pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { BriskConfiguration } from '../common/configuration-options';
import { StageOutput as WebsiteInfoSpec } from '../generate-website-info';

import * as pageWriters from './page-writers';
import getDefaultPagesPath from './get-default-pages-path';

const {
generatePackageDocPage,
Expand All @@ -27,6 +26,8 @@ export type StageInput = {
pagesPath: string;
// The absolute path to the root of the package.
packageRoot: string;
// The absolute path to the directory containing default pages
defaultPagesPath: string;
} & WebsiteInfoSpec &
BriskConfiguration;

Expand All @@ -48,9 +49,8 @@ const generateGenericPage = (
export default createStage(
'generate-pages',
async (input: StageInput): Promise<StageOutput> => {
const { pagesPath, wrappersPath } = input;
const { pagesPath, wrappersPath, defaultPagesPath } = input;
await cleanPages(pagesPath);
const defaultPagesPath = await getDefaultPagesPath();
await addBasePages(defaultPagesPath, pagesPath);

const generatorConfig = { pagesPath, wrappersPath };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { createTempDir } from 'jest-fixtures';
import { createTempDir, copyFixtureIntoTempDir } from 'jest-fixtures';
import path from 'path';
import fs from 'fs-extra';
import generatePagesStage, { StageInput } from './index';

describe('Generate pages build stage integration', () => {
let pagesPath: string;
let wrappersPath: string;
let defaultPagesPath: string;

beforeEach(async () => {
const cwd = await createTempDir();
defaultPagesPath = await copyFixtureIntoTempDir(__dirname, 'default-pages');
pagesPath = path.join(cwd, 'pages');
wrappersPath = path.join(cwd, 'wrappers');
});
Expand All @@ -18,6 +20,7 @@ describe('Generate pages build stage integration', () => {
const input: StageInput = {
pagesPath,
wrappersPath,
defaultPagesPath,
pages: {
packageDocPages: [
{
Expand Down Expand Up @@ -123,5 +126,8 @@ describe('Generate pages build stage integration', () => {
path.join(pagesPath, 'package-home-pages'),
);
expect(packageHomePages).toEqual(['home1.js']);

const rootPages = await fs.readdir(pagesPath);
expect(rootPages).toContain('default-page.js');
});
});
5 changes: 4 additions & 1 deletion packages/pipeline-stages/src/generate-pages/page-writers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,10 @@ export const cleanPages = async (pagesPath: string) => {
* @param defaultPagesPath absolure path to where the default pages are located
* @param pagesPath the pages directory path
*/
export const addBasePages = async (defaultPagesPath: string, pagesPath: string) => {
export const addBasePages = async (
defaultPagesPath: string,
pagesPath: string,
) => {
await fs.copy(defaultPagesPath, pagesPath);
};

Expand Down
1 change: 1 addition & 0 deletions packages/pipeline-stages/src/generate-pages/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jest.mock('./page-writers', () => ({
const inputBase = {
wrappersPath: 'WRAPPERS_PATH',
pagesPath: 'PAGES_PATH',
defaultPagesPath: 'DEFAULT_PAGES_PATH',
pages: {
packageDocPages: [],
projectDocPages: [],
Expand Down
4 changes: 3 additions & 1 deletion packages/react-changelogs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
],
"author": "Aparna Raj",
"license": "MIT",
"files": ["dist"],
"files": [
"dist"
],
"peerDependencies": {
"react": "16.10.2",
"react-dom": "^16.8.4"
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13204,9 +13204,9 @@ [email protected], [email protected], mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1:
minimist "0.0.8"

mock-fs@^4.10.1:
version "4.10.1"
resolved "https://registry.yarnpkg.com/mock-fs/-/mock-fs-4.10.1.tgz#50a07a20114a6cdb119f35762f61f46266a1e323"
integrity sha512-w22rOL5ZYu6HbUehB5deurghGM0hS/xBVyHMGKOuQctkk93J9z9VEOhDsiWrXOprVNQpP9uzGKdl8v9mFspKuw==
version "4.10.4"
resolved "https://packages.atlassian.com/api/npm/npm-remote/mock-fs/-/mock-fs-4.10.4.tgz#4eaa3d6f7da2f44e1f3dd6b462cbbcb7b082e3d4"
integrity sha1-Tqo9b32i9E4fPda0Ysu8t7CC49Q=

[email protected]:
version "2.22.2"
Expand Down

0 comments on commit b97ba11

Please sign in to comment.