Commit b62d5302 authored by David Rhoderick's avatar David Rhoderick
Browse files

Deleting node_modules folder from repository.

parent c9cac309
import chalk from "chalk";
import { errorLogger } from "../utils";
export default async ({
port = 3000,
https = false,
}: {
port?: number;
https?: boolean;
}) => {
let serve: Function;
const options = { port, isHttps: https };
try {
serve = require("@frontity/core").serve;
} catch (error) {
const message =
`Make sure that you are running ${chalk.green(
"frontity"
)} inside a Frontity project.\n` +
`If so try installing ${chalk.green(
"@frontity/core"
)} again with ${chalk.green("npm i @frontity/core")}.\n`;
errorLogger(error, message);
}
try {
await serve(options);
} catch (error) {
errorLogger(error);
}
};
import { EventPromised } from "../utils/eventPromised";
import { subscribe } from "../steps";
// TODO: make param an object
const subscribeCommand = async (
email: string,
emit: (event: string, ...value: any[]) => void,
reject: (reason: any) => void
) => {
try {
emit("message", "Subscribing to frontity");
await subscribe(email);
} catch (error) {
reject(error);
}
};
export default (email: string) =>
// EventPromised is a combination of EventEmitter and Promise
new EventPromised((resolve, reject, emit) => {
subscribeCommand(email, emit, reject).then(() => resolve(true));
});
import "@frontity/type-declarations";
export { css, Global, keyframes } from "@emotion/core";
export { default as styled } from "@emotion/styled";
export { Helmet as Head, HelmetProvider } from "react-helmet-async";
export { default as loadable } from "@loadable/component";
export { observe, batch, useConnect } from "@frontity/connect";
export { error, warn } from "@frontity/error";
import { ConnectFunction, CreateStore } from "@frontity/types/src/connect";
import originalConnect, {
createStore as originalCreateStore,
} from "@frontity/connect";
export const connect = originalConnect as ConnectFunction;
export const createStore = originalCreateStore as CreateStore;
import nodeFetch from "node-fetch";
export const fetch = (nodeFetch as any) as WindowOrWorkerGlobalScope["fetch"];
import decodeClient from "./utils/decode/client";
import decodeServer from "./utils/decode/server";
export const decode =
typeof window !== "undefined" ? decodeClient : decodeServer;
export { default as URL } from "./utils/url";
export { default as useFills } from "./utils/slot-and-fill/use-fills";
export { default as Slot } from "./utils/slot-and-fill/slot";
export { default as create } from "./commands/create";
export { subscribe } from "./steps";
export * from "@frontity/core";
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`cloneStarterTheme works as expected 1`] = `
Array [
Array [
"/path/to/project/package.json",
Object {
"encoding": "utf8",
},
],
]
`;
exports[`cloneStarterTheme works as expected 2`] = `
Array [
Array [
"/path/to/project/packages/mars-theme",
],
]
`;
exports[`cloneStarterTheme works as expected 3`] = `
Array [
Array [
"@frontity/mars-theme",
],
]
`;
exports[`cloneStarterTheme works as expected 4`] = `
Array [
Array [
"npm pack @frontity/mars-theme",
Object {
"cwd": "/path/to/project/packages/mars-theme",
},
[Function],
],
]
`;
exports[`cloneStarterTheme works as expected 5`] = `
Array [
Array [
"/path/to/project/packages/mars-theme",
],
]
`;
exports[`cloneStarterTheme works as expected 6`] = `
Array [
Array [
Object {
"cwd": "/path/to/project/packages/mars-theme",
"file": "/path/to/project/packages/mars-theme/file.tgz",
"strip": 1,
},
],
]
`;
exports[`cloneStarterTheme works as expected 7`] = `
Array [
Array [
"/path/to/project/packages/mars-theme/file.tgz",
],
]
`;
exports[`createFrontitySettings works when extension is \`js\` 1`] = `
Array [
Array [
"/path/to/project/frontity.settings.js",
"{
\\"name\\": \\"random-name\\",
\\"state\\": {
\\"frontity\\": {
\\"url\\": \\"https://test.frontity.org\\",
\\"title\\": \\"Test Frontity Blog\\",
\\"description\\": \\"WordPress installation for Frontity development\\"
}
},
\\"packages\\": [
{
\\"name\\": \\"@frontity/mars-theme\\",
\\"state\\": {
\\"theme\\": {
\\"menu\\": [
[
\\"Home\\",
\\"/\\"
],
[
\\"Nature\\",
\\"/category/nature/\\"
],
[
\\"Travel\\",
\\"/category/travel/\\"
],
[
\\"Japan\\",
\\"/tag/japan/\\"
],
[
\\"About Us\\",
\\"/about-us/\\"
]
],
\\"featured\\": {
\\"showOnList\\": false,
\\"showOnPost\\": false
}
}
}
},
{
\\"name\\": \\"@frontity/wp-source\\",
\\"state\\": {
\\"source\\": {
\\"url\\": \\"https://test.frontity.org\\"
}
}
},
\\"@frontity/tiny-router\\",
\\"@frontity/html2react\\"
]
}",
],
]
`;
exports[`createFrontitySettings works when extension is \`ts\` 1`] = `
Array [
Array [
"/path/to/project/frontity.settings.ts",
"{
\\"name\\": \\"random-name\\",
\\"state\\": {
\\"frontity\\": {
\\"url\\": \\"https://test.frontity.org\\",
\\"title\\": \\"Test Frontity Blog\\",
\\"description\\": \\"WordPress installation for Frontity development\\"
}
},
\\"packages\\": [
{
\\"name\\": \\"@frontity/mars-theme\\",
\\"state\\": {
\\"theme\\": {
\\"menu\\": [
[
\\"Home\\",
\\"/\\"
],
[
\\"Nature\\",
\\"/category/nature/\\"
],
[
\\"Travel\\",
\\"/category/travel/\\"
],
[
\\"Japan\\",
\\"/tag/japan/\\"
],
[
\\"About Us\\",
\\"/about-us/\\"
]
],
\\"featured\\": {
\\"showOnList\\": false,
\\"showOnPost\\": false
}
}
}
},
{
\\"name\\": \\"@frontity/wp-source\\",
\\"state\\": {
\\"source\\": {
\\"url\\": \\"https://test.frontity.org\\"
}
}
},
\\"@frontity/tiny-router\\",
\\"@frontity/html2react\\"
]
}",
],
]
`;
exports[`createPackageJson for create-package works with a theme like "@frontity/mars-theme" 1`] = `
Array [
Array [
"frontity",
],
]
`;
exports[`createPackageJson for create-package works with a theme like "@frontity/mars-theme" 2`] = `
Array [
Array [
"@frontity/mars-theme//path/to/project/package.json",
"{
\\"name\\": \\"random-name\\",
\\"version\\": \\"1.0.0\\",
\\"description\\": \\"Frontity package created using the Frontity CLI.\\",
\\"keywords\\": [
\\"frontity\\",
\\"frontity-test\\"
],
\\"license\\": \\"Apache-2.0\\",
\\"dependencies\\": {
\\"frontity\\": \\"^1.0.0\\"
}
}
",
],
]
`;
exports[`createPackageJson for create-package works with a theme like "random-theme" 1`] = `
Array [
Array [
"frontity",
],
]
`;
exports[`createPackageJson for create-package works with a theme like "random-theme" 2`] = `
Array [
Array [
"random-theme//path/to/project/package.json",
"{
\\"name\\": \\"random-name\\",
\\"version\\": \\"1.0.0\\",
\\"description\\": \\"Frontity package created using the Frontity CLI.\\",
\\"keywords\\": [
\\"frontity\\",
\\"frontity-test\\"
],
\\"license\\": \\"Apache-2.0\\",
\\"dependencies\\": {
\\"frontity\\": \\"^1.0.0\\"
}
}
",
],
]
`;
exports[`createPackageJson works with a theme like "@frontity/mars-theme" 1`] = `
Array [
Array [
"frontity",
],
Array [
"@frontity/core",
],
Array [
"@frontity/wp-source",
],
Array [
"@frontity/tiny-router",
],
Array [
"@frontity/html2react",
],
]
`;
exports[`createPackageJson works with a theme like "@frontity/mars-theme" 2`] = `
Array [
Array [
"/path/to/project/package.json",
"{
\\"name\\": \\"random-name\\",
\\"version\\": \\"1.0.0\\",
\\"private\\": true,
\\"description\\": \\"Frontity project\\",
\\"keywords\\": [
\\"frontity\\"
],
\\"engines\\": {
\\"node\\": \\">=10.0.0\\",
\\"npm\\": \\">=6.0.0\\"
},
\\"scripts\\": {
\\"dev\\": \\"frontity dev\\",
\\"build\\": \\"frontity build\\",
\\"serve\\": \\"frontity serve\\"
},
\\"prettier\\": {},
\\"dependencies\\": {
\\"frontity\\": \\"^1.0.0\\",
\\"@frontity/core\\": \\"^1.0.0\\",
\\"@frontity/wp-source\\": \\"^1.0.0\\",
\\"@frontity/tiny-router\\": \\"^1.0.0\\",
\\"@frontity/html2react\\": \\"^1.0.0\\",
\\"@frontity/mars-theme\\": \\"./packages/mars-theme\\"
}
}
",
],
]
`;
exports[`createPackageJson works with a theme like "mars-theme" 1`] = `
Array [
Array [
"frontity",
],
Array [
"@frontity/core",
],
Array [
"@frontity/wp-source",
],
Array [
"@frontity/tiny-router",
],
Array [
"@frontity/html2react",
],
]
`;
exports[`createPackageJson works with a theme like "mars-theme" 2`] = `
Array [
Array [
"/path/to/project/package.json",
"{
\\"name\\": \\"random-name\\",
\\"version\\": \\"1.0.0\\",
\\"private\\": true,
\\"description\\": \\"Frontity project\\",
\\"keywords\\": [
\\"frontity\\"
],
\\"engines\\": {
\\"node\\": \\">=10.0.0\\",
\\"npm\\": \\">=6.0.0\\"
},
\\"scripts\\": {
\\"dev\\": \\"frontity dev\\",
\\"build\\": \\"frontity build\\",
\\"serve\\": \\"frontity serve\\"
},
\\"prettier\\": {},
\\"dependencies\\": {
\\"frontity\\": \\"^1.0.0\\",
\\"@frontity/core\\": \\"^1.0.0\\",
\\"@frontity/wp-source\\": \\"^1.0.0\\",
\\"@frontity/tiny-router\\": \\"^1.0.0\\",
\\"@frontity/html2react\\": \\"^1.0.0\\",
\\"random-theme\\": \\"./packages/random-theme\\"
}
}
",
],
]
`;
exports[`downloadFavicon works as expected 1`] = `
Array [
Array [
"https://favicon.frontity.org/",
],
]
`;
exports[`downloadFavicon works as expected 2`] = `
Array [
Array [
"/path/to/project/favicon.ico",
],
]
`;
exports[`ensureProjectDir works when passing a non existent path 1`] = `
Array [
Array [
"/path/to/project",
],
]
`;
exports[`ensureProjectDir works when passing a non existent path 2`] = `
Array [
Array [
"/path/to/project",
],
]
`;
exports[`ensureProjectDir works when passing an existent path with an empty repo 1`] = `
Array [
Array [
"/path/to/project",
],
]
`;
exports[`ensureProjectDir works when passing an existent path with an empty repo 2`] = `
Array [
Array [
"/path/to/project",
],
]
`;
exports[`installDependencies works as expected 1`] = `
Array [
Array [
"npm install",
Object {
"cwd": "/path/to/project",
},
[Function],
],
]
`;
exports[`revertProgress works if the project directory didn't exist 1`] = `
Array [
Array [
"/path/to/project",
],
]
`;
exports[`revertProgress works if the project directory existed 1`] = `
Array [
Array [
"/path/to/project",
],
]
`;
exports[`revertProgress works if the project directory existed 2`] = `
Array [
Array [
"/path/to/project/frontity.settings.js",
],
Array [
"/path/to/project/package.json",
],
Array [
"/path/to/project/packages",
],
Array [
"/path/to/project/favicon.ico",
],
Array [
"/path/to/project/node_modules",
],
Array [
"/path/to/project/package-lock.json",
],
]
`;
import {
normalizeOptions,
ensureProjectDir,
createPackageJson,
createFrontitySettings,
cloneStarterTheme,
installDependencies,
downloadFavicon,
revertProgress,
} from "../";
import {
createPackageJson as createPackageJsonForPackage,
createSrcIndexJs,
installPackage,
} from "../create-package";
import * as utils from "../../utils";
import * as fsExtra from "fs-extra";
import * as fetch from "node-fetch";
import * as path from "path";
import * as childProcess from "child_process";
import * as tar from "tar";
jest.mock("../../utils");
jest.mock("fs-extra");
jest.mock("path");
jest.mock("node-fetch");
jest.mock("child_process");
jest.mock("tar");
const mockedUtils = utils as jest.Mocked<typeof utils>;
const mockedFsExtra = fsExtra as jest.Mocked<typeof fsExtra>;
const mockedFetch = fetch as jest.Mocked<typeof fetch>;
const mockedPath = path as jest.Mocked<typeof path>;
const mockedChildProcess = childProcess as jest.Mocked<typeof childProcess>;
const mockedTar = tar as jest.Mocked<typeof tar>;
beforeEach(() => {
mockedPath.resolve.mockImplementation((...dirs) =>