Skip to content

Commit

Permalink
[SDPA-3172] Update create-ripple-app to 1.2.0 (#504)
Browse files Browse the repository at this point in the history
* Update create-ripple-app to 1.1.0-alpha.0

* make update script source folder configurable

* Remove redundant cypress commands in project root

* Update ripple nuxt tide version

* Cleanup dependencies, remove babel from example app

* fix cypress dependencies

* fix runtests script

* CR Changes - Fix module array in config

* restore ol transform in jest config

* Update CRA to latest version

* remove console
  • Loading branch information
dylankelly authored Sep 9, 2019
1 parent cb9ab26 commit f8474b3
Show file tree
Hide file tree
Showing 26 changed files with 148 additions and 121 deletions.
11 changes: 0 additions & 11 deletions examples/vic-gov-au/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,8 @@
"run-script-os": "^1.0.7"
},
"devDependencies": {
"@babel/core": "^7.5.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.5.0",
"@babel/runtime": "^7.5.1",
"@dpc-sdp/ripple-test-tools": "1.1.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.8.0",
"babel-plugin-dynamic-import-node": "^2.3.0",
"babel-plugin-require-context-hook": "^1.0.0",
"babel-preset-vue": "^2.0.2",
"core-js": "^2.6.5",
"cross-env": "^5.2.0",
"cypress": "^3.1.5",
"cypress-axe": "^0.4.0",
Expand Down
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
"test:unit": "jest --colors",
"build:storybook": "cd src && yarn build-storybook",
"build:example": "cd examples/vic-gov-au && yarn run build",
"cy:open": "cypress open",
"cy:run": "cypress run -e TAGS='not @skip or @smoke'",
"cy:run-smoke": "cypress run -e TAGS='@smoke'",
"lint": "eslint --ext .js,.vue . --max-warnings 0 && sass-lint",
"lint:fix": "eslint --ext .js,.vue . --fix",
"bay:start": "docker-compose up -d",
Expand All @@ -49,16 +46,17 @@
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.5.0",
"@ljharb/eslint-config": "^13.1.1",
"@vue/test-utils": "^1.0.0-beta.29",
"axe-core": "^3.2.2",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.8.0",
"babel-plugin-dynamic-import-node": "^2.3.0",
"babel-plugin-require-context-hook": "^1.0.0",
"babel-preset-vue": "^2.0.2",
"babel-eslint": "^10.0.1",
"@ljharb/eslint-config": "^13.1.1",
"axe-core": "^3.2.2",
"@vue/test-utils": "^1.0.0-beta.29",
"cross-env": "^5.2.0",
"core-js": "^2.6.5",
"eslint": "^5.11.1",
"eslint-config-standard": "^12.0.0",
"eslint-friendly-formatter": "^3.0.0",
Expand Down
87 changes: 75 additions & 12 deletions packages/create-ripple-app/saofile.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ const OPTIONS = {
type: 'string',
default: '{outFolder}'
},
description: {
name: 'description',
message: 'Project description',
domain: {
name: 'domain',
message: 'Domain',
default: ({ name }) => {
return `${name || config.name}.vic.gov.au`
}
Expand Down Expand Up @@ -95,6 +95,18 @@ const OPTIONS = {
type: 'confirm',
default: true
},
smoke: {
name: 'smoke',
message: 'Add Integration tests?',
type: 'confirm',
default: true
},
unit: {
name: 'unit',
message: 'Add unit tests?',
type: 'confirm',
default: true
},
examples: {
name: 'examples',
message: 'Add code examples?',
Expand Down Expand Up @@ -172,7 +184,7 @@ const config = {
// set options via interactive prompt if not defined by config
const prompts = []
Object.values(OPTIONS).forEach(option => {
if (!config[option.name]) {
if (config[option.name] === undefined) {
prompts.push(option)
}
})
Expand All @@ -182,16 +194,18 @@ module.exports = {
return prompts
},
templateData () {
if (config.modules && !Array.isArray(config.modules)) {
config.modules = config.modules.split(',')
}
const results = {
...this.answers,
...config
}

const paramModules = results.modules || []
const tideModules = {}

TIDE_MODULES.map(m => m.value).forEach(module => {
if (paramModules.includes(module) || results.modules.includes(module)) {
if (results.modules.includes(module)) {
tideModules[module] = 'yes'
} else {
tideModules[module] = 'no'
Expand All @@ -204,12 +218,17 @@ module.exports = {
}
},
actions () {
if (config.modules && !Array.isArray(config.modules)) {
config.modules = config.modules.split(',')
}

const results = {
...this.answers,
...config
}

const validation = validate(results.name)

validation.warnings &&
validation.warnings.forEach(warn => {
console.warn('Warning:', warn)
Expand Down Expand Up @@ -237,6 +256,28 @@ module.exports = {
}
]

const removePath = (path, actions) => {
if (fs.existsSync(`${this.outDir}${path}`)) {
return actions.push({
type: 'remove',
files: path
})
}
}
const movePath = (from, to, actions) => {
if (fs.existsSync(`${this.outDir}${from}`)) {
return actions.push({
type: 'move',
patterns: {
from: to
}
})
}
}

removePath('/pages/Sitemap.vue', actions)
movePath('/tide.config.js', '/tide/tide.config.js', actions)

if (results.examples) {
actions.push({
type: 'add',
Expand All @@ -248,19 +289,37 @@ module.exports = {
actions.push({
type: 'move',
patterns: {
gitignore: '.gitignore',
'_package.json': 'package.json',
'_.env': '.env'
}
})

if (results.e2e) {
if (results.unit) {
actions.push({
type: 'move',
patterns: {
'_jest.config.js': 'jest.config.js'
}
})
}

if (results.e2e || results.smoke) {
actions.push({
type: 'add',
files: ['**'],
templateDir: 'template/_tests/_common'
})
}

if (results.smoke) {
actions.push({
type: 'add',
files: ['**'],
templateDir: 'template/_tests/_smoke'
})
}

if (results.e2e) {
// only add tests for enabled modules
results.modules.forEach(tideModule => {
const hasTests = fs.existsSync(path.resolve(__dirname, `./template/_tests/_modules/test/e2e/integration/core-modules/${tideModule}`))
Expand All @@ -280,8 +339,12 @@ module.exports = {
},
async completed () {
// this.gitInit()
const results = {
...this.answers,
...config
}

await this.npmInstall({ npmClient: this.answers.pm })
await this.npmInstall({ npmClient: results.pm })

const isNewFolder = this.outDir !== process.cwd()
const cd = () => {
Expand All @@ -293,11 +356,11 @@ module.exports = {
console.log()
console.log(this.chalk.bold(` To get started:\n`))
cd()
console.log(`\t${this.answers.pm} run dev\n`)
console.log(`\t${results.pm} run dev\n`)
console.log(this.chalk.bold(` To build & start for production:\n`))
cd()
console.log(`\t${this.answers.pm} run build`)
console.log(`\t${this.answers.pm} start`)
console.log(`\t${results.pm} run build`)
console.log(`\t${results.pm} start`)
console.log()
}
}
2 changes: 1 addition & 1 deletion packages/create-ripple-app/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ We will build a guide of variables in future. But for now, you can check [Ripple

### Custom scss

You can orveride styles in [assets/_custom.scss](assets/_custom.scss) by adding any site specific styles.
You can overide styles in [assets/_custom.scss](assets/_custom.scss) by adding any site specific styles.

### Custom static files

Expand Down
3 changes: 1 addition & 2 deletions packages/create-ripple-app/template/_.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Copy this .env.example to .env in your local dev environment.
# Tide API
CONTENT_API_SERVER=<%= backendurl %>
CONTENT_API_AUTH_USER=<%= authuser %>
Expand All @@ -10,7 +9,7 @@ GTM_ID=<%= gtmtoken %>
# This will enable Nuxt debug and display error details.
DISPLAY_ERROR=1

# Search settings
# Search settings - NONPROD
SEARCH_HASH=<%= searchhash %>
SEARCH_SERVICE=elasticsearch
SEARCH_INDEX=<%= searchindex %>
Expand Down
16 changes: 16 additions & 0 deletions packages/create-ripple-app/template/_jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
verbose: true,
moduleNameMapper: {
'~(.*)$': '<rootDir>/$1', // Add nuxt root alias in jest
'^vue$': 'vue/dist/vue.esm.js'
},
testURL: 'http://localhost',
collectCoverage: true,
testMatch: ['**/*.test.js'],
moduleFileExtensions: ['js', 'vue', 'json'],
transform: {
'^.+\\.js$': 'babel-jest',
'.*\\.(vue)$': 'vue-jest'
},
transformIgnorePatterns: ['node_modules/(?!(@dpc-sdp*)/)']
}
53 changes: 26 additions & 27 deletions packages/create-ripple-app/template/_package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
{
"name": "<%= name %>",
"version": "1.0.0",
"description": "<%= description %>",
"description": "<%= domain %>",
"author": "<%= author %>",
"private": true,
"scripts": {
"dev": "cross-env BASIC_AUTH=0 nuxt",
"build": "run-script-os",
"build:default": "if [ \"$NUXT_HOT_RELOADING\" != \"1\" ] ; then nuxt build; fi",
"build:win32": "IF \"%NUXT_HOT_RELOADING%\" NEQ \"1\" ( nuxt build )",
<%_ if (e2e === true) { _%>
<%_ if ((e2e === true) || (smoke === true)) { _%>
"cy:open": "cypress open",
"cy:run": "cypress run -e TAGS='not @skip or @smoke'",
"cy:run-smoke": "cypress run -e TAGS='@smoke'",
<%_ if (e2e === true) { _%>
"cy:run": "cypress run -e TAGS='not @skip or @smoke'",
"test:e2e": "cross-env NODE_ENV=test BASIC_AUTH=0 start-server-and-test start:build http://localhost:3000 cy:run",
<%_ } _%>
"test:dev": "cross-env NODE_ENV=dev start-server-and-test dev http://localhost:3000 cy:open",
"test:smoke": "cross-env NODE_ENV=test start-server-and-test start:build http://localhost:3000 cy:run-smoke",
"test:e2e": "cross-env NODE_ENV=test start-server-and-test start:build http://localhost:3000 cy:run",
"test:smoke": "cross-env NODE_ENV=test BASIC_AUTH=0 start-server-and-test start:build http://localhost:3000 cy:run-smoke",
<%_ } _%>
<%_ if (unit === true) { _%>
"test:unit": "BASIC_AUTH=0 NODE_ENV=test jest --passWithNoTests",
<%_ } _%>
"lint": "eslint --ext .js,.vue . --max-warnings 0 && sass-lint",
"start": "run-script-os",
Expand All @@ -24,32 +29,17 @@
"start:build": "nuxt build && nuxt start"
},
"dependencies": {
"@dpc-sdp/ripple-nuxt-tide": "^1.0.0",
"@dpc-sdp/ripple-nuxt-tide": "^1.2.0",
"dotenv": "^5.0.1",
"nuxt": "2.6.3",
"run-script-os": "^1.0.7"
},
"devDependencies": {
<%_ if (e2e === true) { _%>
"@dpc-sdp/ripple-test-tools": "^1.0.0",
"cypress": "^3.1.5",
"cypress-axe": "^0.4.0",
"axe-core": "^3.3.1",
"cypress-cucumber-preprocessor": "^1.11.0",
<%_ if ((e2e === true) || (smoke === true)) { _%>
"@dpc-sdp/ripple-test-tools": "^1.2.0",
"start-server-and-test": "^1.7.11",
<%_ } _%>
"@babel/core": "^7.5.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.5.0",
"@babel/runtime": "^7.5.1",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.8.0",
"babel-plugin-dynamic-import-node": "^2.3.0",
"babel-plugin-require-context-hook": "^1.0.0",
"babel-preset-vue": "^2.0.2",
"core-js": "^2.6.5",
"cross-env": "^5.2.0",
"eslint": "^4.15.0",
"eslint-config-standard": "^10.2.1",
Expand All @@ -61,13 +51,17 @@
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vue": "^4.0.0",
<%_ if (unit === true) { _%>
"jest": "^24.9.0",
"vue-jest": "^3.0.4",
<%_ } _%>
"husky": "^3.0.0",
"node-sass": "^4.11.0",
"sass-lint": "^1.12.1",
"sass-loader": "^6.0.7",
"sass-resources-loader": "^2.0.0",
"vue-jest": "^3.0.4"
"sass-resources-loader": "^2.0.0"
},
<%_ if (e2e === true) { _%>
<%_ if ((e2e === true) || (smoke === true)) { _%>
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true
},
Expand All @@ -77,5 +71,10 @@
"IE 11",
"last 2 versions",
"not ie <= 8"
]
],
"husky": {
"hooks": {
"pre-push": "<%= pm %> run lint<%_ if (unit === true) { _%> && <%= pm %>run test:unit<%_ } _%>"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"screenshotsFolder": "test/e2e/screenshots",
"supportFile": "test/e2e/support/index.js",
"videosFolder": "test/e2e/videos",
"ignoreTestFiles": "*.js"
"ignoreTestFiles": ["*.js","*.md"]
}
Loading

0 comments on commit f8474b3

Please sign in to comment.