Skip to content

Commit

Permalink
Merge pull request #5 from form8ion/alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
travi authored Jul 27, 2020
2 parents c848891 + 3d60075 commit 53be26c
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 9 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ overrides:
- files: example.js
rules:
import/no-extraneous-dependencies: off

- files: templates/*.js
rules:
import/no-unresolved: off
import/extensions: off
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"version": "0.0.0-semantically-released",
"files": [
"example.js",
"lib/"
"lib/",
"templates/"
],
"publishConfig": {
"access": "public"
Expand Down
7 changes: 0 additions & 7 deletions src/canary-test.js

This file was deleted.

30 changes: 30 additions & 0 deletions src/config-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {promises as fs} from 'fs';
import {resolve} from 'path';
import sinon from 'sinon';
import {assert} from 'chai';
import any from '@travi/any';
import scaffoldConfig from './config';

suite('config', () => {
let sandbox;

setup(() => {
sandbox = sinon.createSandbox();

sandbox.stub(fs, 'copyFile');
});

teardown(() => sandbox.restore());

test('that the config file is created', async () => {
const projectRoot = any.string();

await scaffoldConfig({projectRoot});

assert.calledWith(
fs.copyFile,
resolve(__dirname, '..', 'templates', 'nuxt.config.js'),
`${projectRoot}/nuxt.config.js`
);
});
});
6 changes: 6 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {promises as fs} from 'fs';
import {resolve} from 'path';

export default async function ({projectRoot}) {
await fs.copyFile(resolve(__dirname, '..', 'templates', 'nuxt.config.js'), `${projectRoot}/nuxt.config.js`);
}
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {default as scaffold} from './scaffold';
39 changes: 39 additions & 0 deletions src/scaffold-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {assert} from 'chai';
import sinon from 'sinon';
import any from '@travi/any';
import * as config from './config';
import scaffold from './scaffold';

suite('scaffold', () => {
let sandbox;

setup(() => {
sandbox = sinon.createSandbox();

sandbox.stub(config, 'default');
});

teardown(() => sandbox.restore());

test('that nuxt dependencies are defined', async () => {
const projectRoot = any.string();

const {dependencies, devDependencies, scripts, vcsIgnore, buildDirectory} = await scaffold({projectRoot});

assert.calledWith(config.default, {projectRoot});
assert.deepEqual(dependencies, ['nuxt']);
assert.deepEqual(devDependencies, ['@vue/test-utils', '@nuxtjs/eslint-module']);
assert.deepEqual(buildDirectory, 'dist/');
assert.deepEqual(vcsIgnore.directories, ['.nuxt/']);
assert.deepEqual(
scripts,
{
dev: 'nuxt',
build: 'nuxt build',
start: 'nuxt start',
export: 'nuxt export',
serve: 'nuxt serve'
}
);
});
});
19 changes: 19 additions & 0 deletions src/scaffold.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import scaffoldConfig from './config';

export default async function ({projectRoot}) {
await scaffoldConfig({projectRoot});

return {
scripts: {
dev: 'nuxt',
build: 'nuxt build',
start: 'nuxt start',
export: 'nuxt export',
serve: 'nuxt serve'
},
dependencies: ['nuxt'],
devDependencies: ['@vue/test-utils', '@nuxtjs/eslint-module'],
buildDirectory: 'dist/',
vcsIgnore: {directories: ['.nuxt/']}
};
}
59 changes: 59 additions & 0 deletions templates/nuxt.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
export default {
/*
** Nuxt rendering mode
** See https://nuxtjs.org/api/configuration-mode
*/
mode: 'spa',
/*
** Nuxt target
** See https://nuxtjs.org/api/configuration-target
*/
target: 'static',
/*
** Headers of the page
** See https://nuxtjs.org/api/configuration-head
*/
head: {
title: process.env.npm_package_name || '',
meta: [
{charset: 'utf-8'},
{name: 'viewport', content: 'width=device-width, initial-scale=1'},
{
hid: 'description',
name: 'description',
content: process.env.npm_package_description || ''
}
],
link: [{rel: 'icon', type: 'image/x-icon', href: '/favicon.ico'}]
},
/*
** Global CSS
*/
css: [],
/*
** Plugins to load before mounting the App
** https://nuxtjs.org/guide/plugins
*/
plugins: [],
/*
** Auto import components
** See https://nuxtjs.org/api/configuration-components
*/
components: true,
/*
** Nuxt.js dev-modules
*/
buildModules: [
// Doc: https://github.com/nuxt-community/eslint-module
'@nuxtjs/eslint-module'
],
/*
** Nuxt.js modules
*/
modules: [],
/*
** Build configuration
** See https://nuxtjs.org/api/configuration-build/
*/
build: {}
};

0 comments on commit 53be26c

Please sign in to comment.