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

chore: rename starter template directory #200

Merged
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
4 changes: 1 addition & 3 deletions __e2e__/commands/add.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import { DOWN, ENTER, SPACE } from 'cli-prompts-test';
import fs from 'fs';
import path from 'path';

// Create a temp directory
const tempDirPath = path.join(__dirname, 'add-cmd');
fs.mkdirSync(tempDirPath);

const genPath = path.join(tempDirPath, 'my-app');

// The client directory
Expand All @@ -18,6 +15,7 @@ const serverPath = path.join(genPath, 'server');

describe('mevn add', () => {
// cleanup
beforeAll(() => fs.mkdirSync(tempDirPath));
afterAll(() => rmTempDir(tempDirPath));

it('installs Nuxt.js modules if no args were passed in', async () => {
Expand Down
5 changes: 2 additions & 3 deletions __e2e__/commands/codesplit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ import { DOWN, ENTER } from 'cli-prompts-test';
import fs from 'fs';
import path from 'path';

// Create a temp directory
const tempDirPath = path.join(__dirname, 'codesplit-cmd');
fs.mkdirSync(tempDirPath);

const genPath = path.join(tempDirPath, 'my-app');

// The client directory
const clientPath = path.join(genPath, 'client');

describe('mevn codesplit', () => {
// Cleanup
beforeAll(() => fs.mkdirSync(tempDirPath));
afterAll(() => rmTempDir(tempDirPath));

it('dynamically imports a component', async () => {
Expand Down
6 changes: 2 additions & 4 deletions __e2e__/commands/generate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import { DOWN, ENTER } from 'cli-prompts-test';
import fs from 'fs';
import path from 'path';

// Create a temp directory
const tempDirPath = path.join(__dirname, 'generate-cmd');
fs.mkdirSync(tempDirPath);

const genPath = path.join(tempDirPath, 'my-app');

// The client directory
Expand All @@ -23,7 +20,8 @@ const pageComponentPath = path.join(clientPath, 'src', 'views');
const serverPath = path.join(genPath, 'server');

describe('mevn generate', () => {
// cleanup
// Cleanup
beforeAll(() => fs.mkdirSync(tempDirPath));
afterAll(() => rmTempDir(tempDirPath));

it('generates a UI component', async () => {
Expand Down
45 changes: 40 additions & 5 deletions __e2e__/commands/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ import { DOWN, ENTER } from 'cli-prompts-test';
import fs from 'fs';
import path from 'path';

// Create a temp directory
const tempDirPath = path.join(__dirname, 'init-cmd');
fs.mkdirSync(tempDirPath);

const genPath = path.join(tempDirPath, 'my-app');

const clientPath = path.join(genPath, 'client');
const serverPath = path.join(genPath, 'server');

describe('mevn init', () => {
// Cleanup
beforeAll(() => fs.mkdirSync(tempDirPath));
afterAll(() => rmTempDir(tempDirPath));

it('shows an appropriate warning if multiple arguments were provided with init', () => {
Expand All @@ -37,7 +36,7 @@ describe('mevn init', () => {
`${DOWN}${DOWN}${DOWN}${ENTER}`, // Choose Nuxt.js as the starter template
`${DOWN}${ENTER}`, // Choose spa as the rendering mode
`${DOWN}${ENTER}`, // Choose static as the deploy target
`Y${ENTER}`, // Requires server directory
`${ENTER}`, // Requires server directory
],
tempDirPath,
);
Expand Down Expand Up @@ -88,18 +87,54 @@ describe('mevn init', () => {
['init', 'my-app'],
[
`${DOWN}${DOWN}${ENTER}`, // Choose GraphQL as the starter template
`Y${ENTER}`, // Requires server directory
`${ENTER}`, // Requires server directory
],
tempDirPath,
);

expect(fetchProjectConfig(genPath).template).toBe('GraphQL');
expect(fetchProjectConfig(genPath).isConfigured.client).toBe(false);
expect(fetchProjectConfig(genPath).isConfigured.server).toBe(false);

// Rename .mevngitignore to .gitignore
expect(fs.existsSync(path.join(clientPath, '.mevngitignore'))).toBeFalsy();
expect(fs.existsSync(path.join(clientPath, '.gitignore'))).toBeTruthy();

// Check whether if the respective directory have been generated
expect(fs.existsSync(path.join(serverPath, 'graphql'))).toBeTruthy();

// Delete the generated directory
rmTempDir(genPath);
});

it('creates a new MEVN stack webapp based on the PWA starter template', async () => {
await runPromptWithAnswers(
['init', 'my-app'],
[
`${DOWN}${ENTER}`, // Choose PWA as the starter template
`${ENTER}`, // Requires server directory
],
tempDirPath,
);

expect(fetchProjectConfig(genPath).template).toBe('PWA');
expect(fetchProjectConfig(genPath).isConfigured.client).toBe(false);
expect(fetchProjectConfig(genPath).isConfigured.server).toBe(false);

// Rename .mevngitignore to .gitignore
expect(fs.existsSync(path.join(clientPath, '.mevngitignore'))).toBeFalsy();
expect(fs.existsSync(path.join(clientPath, '.gitignore'))).toBeTruthy();

// Check whether if the respective directory have been generated
expect(fs.existsSync(path.join(serverPath))).toBeTruthy();

// Assert for files specific to the starter template
expect(fs.existsSync(path.join(clientPath, 'public', 'img'))).toBeTruthy();
expect(
fs.existsSync(path.join(clientPath, 'public', 'manifest.json')),
).toBeTruthy();
expect(
fs.existsSync(path.join(clientPath, 'src', 'registerServiceWorker.js')),
).toBeTruthy();
});
});