From 07c40a913aa2272f31daa40a0671a0fae8af19da Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sun, 18 Mar 2018 23:41:43 +0330 Subject: [PATCH] build-fixtures script --- package.json | 1 + scripts/build-fixtures | 57 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100755 scripts/build-fixtures diff --git a/package.json b/package.json index a1759ca58d..b46814fe79 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "setupTestFrameworkScriptFile": "./test/helpers/setup" }, "scripts": { + "build-fixtures": "./scripts/build-fixtures", "test": "npm run lint && jest", "test-appveyor": "yarn test", "coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov", diff --git a/scripts/build-fixtures b/scripts/build-fixtures new file mode 100755 index 0000000000..f5fc464ee2 --- /dev/null +++ b/scripts/build-fixtures @@ -0,0 +1,57 @@ +#!/usr/bin/env node +process.env.NODE_ENV = 'test' + +const { Builder, Nuxt } = require('..') +const { requireModule } = require('../lib/common/module') +const path = require('path') +const fs = require('fs') +const ORA = require('ora') + +const fixtures = [ + // csr, dev, generate, fail generate, fallback generate, ssr, ssr csp, spa + 'basic', + + 'children', + 'custom-dirs', + 'debug', + 'deprecate', + 'dynamic-routes', + 'empty', + 'error', + 'module', + 'ssr', + 'with-config' +] + +const spinner = new ORA() + +async function buildFixture(name) { + spinner.info('Loading config for fixture ' + name) + + const rootDir = path.resolve(__dirname, '../test/fixtures', name) + const configFile = path.resolve(rootDir, 'nuxt.config.js') + const config = fs.existsSync(configFile) ? requireModule(configFile) : {} + + config.rootDir = rootDir + + spinner.start('Building fixture ' + name) + + const nuxt = new Nuxt(config) + const builder = new Builder(nuxt) + + await builder.build() + + spinner.succeed('Built fixture ' + name) + + await nuxt.close() +} + +async function run() { + for (let fixture of fixtures) { + await buildFixture(fixture) + } +} + +run() + .catch(console.error) // eslint-disable-line no-console + .then(() => process.exit(0))