@cnamts/vue-cli-plugin-vue-dash
Advanced tools
Comparing version 2.0.0-alpha.47 to 2.0.0-alpha.48
@@ -8,3 +8,3 @@ const vdPkg = require('../../package.json'); | ||
dependencies: { | ||
'@cnamts/vue-dot': `^${VueDotVersion}`, | ||
'@cnamts/vue-dot': `${VueDotVersion}`, | ||
'axios': '^0.19.2', | ||
@@ -11,0 +11,0 @@ 'core-js': '^3.6.4', |
@@ -1,2 +0,1 @@ | ||
const path = require('path'); | ||
const fs = require('fs-extra'); | ||
@@ -10,5 +9,11 @@ | ||
/** Fix package.json indentation (from 2 spaces to tabs) */ | ||
function fixPackageIndentation() { | ||
const packagePath = getPath('package.json'); | ||
function fixPackageIndentation(invoking, packageName) { | ||
let packagePath; | ||
if (invoking) { | ||
packagePath = getPath('package.json'); | ||
} else { | ||
packagePath = getPath(packageName + '/package.json'); | ||
} | ||
const package = fs.readFileSync(packagePath).toString(); | ||
@@ -15,0 +20,0 @@ |
@@ -46,2 +46,12 @@ /** | ||
path: 'tests/e2e/specs/test.js' | ||
}, | ||
{ | ||
type: 'file', | ||
path: 'cypress.json', | ||
condition: !options.cypress | ||
}, | ||
{ | ||
type: 'folder', | ||
path: 'tests/e2e/', | ||
condition: !options.cypress | ||
} | ||
@@ -48,0 +58,0 @@ ]; |
@@ -9,32 +9,44 @@ const getFooterDate = require('./functions/getFooterDate'); | ||
const shouldRenderTemplate = require('../shouldRenderTemplate'); | ||
const { capitalizeFirstLetter } = require('../utils'); | ||
module.exports = (api, userOptions) => { | ||
const options = { | ||
...userOptions, | ||
// Custom options | ||
name: api.rootOptions.projectName, | ||
footerDate: getFooterDate(), | ||
pm: 'yarn', | ||
// Functions | ||
capitalizeFirstLetter | ||
}; | ||
const projectName = api.rootOptions.projectName; | ||
api.render('./template', options); | ||
// By default, do not render template when invoking | ||
// except if --render-template option is provided | ||
// (this prevents erasing an entire project by accident) | ||
if (shouldRenderTemplate) { | ||
const options = { | ||
...userOptions, | ||
// Custom options | ||
name: projectName, | ||
footerDate: getFooterDate(), | ||
pm: 'yarn', | ||
cypress: false, // Disable cypress for now | ||
// Functions | ||
capitalizeFirstLetter | ||
}; | ||
// Update package.json | ||
extendPackage(api, options); | ||
api.render('./template', options); | ||
api.postProcessFiles((resources) => { | ||
const resourcesToDelete = getResourcesToDelete(options); | ||
deleteOldResources(resources, resourcesToDelete); | ||
// Update package.json | ||
extendPackage(api, options); | ||
const indexPath = 'public/index.html'; | ||
resources[indexPath] = parseIndexFile(resources[indexPath]); | ||
}); | ||
// Delete old ressources and parse public/index.html | ||
api.postProcessFiles((resources) => { | ||
const resourcesToDelete = getResourcesToDelete(options); | ||
deleteOldResources(resources, resourcesToDelete); | ||
// Delete old resources after writing files to disk | ||
const indexPath = 'public/index.html'; | ||
resources[indexPath] = parseIndexFile(resources[indexPath]); | ||
}); | ||
} | ||
// Fix package indentation after writing files to the disk | ||
// Even if no template is rendered the indentation is modified | ||
api.onCreateComplete(() => { | ||
fixPackageIndentation(); | ||
fixPackageIndentation(api.invoking, projectName); | ||
}); | ||
}; |
// Global test configuration | ||
import Vue from 'vue'; | ||
import VueTestUtils, | ||
import { | ||
createLocalVue, | ||
mount, | ||
shallowMount, | ||
MountOptions, | ||
ShallowMountOptions, | ||
Wrapper, | ||
VueClass, | ||
MountOptions, | ||
ShallowMountOptions | ||
config | ||
} from '@vue/test-utils';<% if (i18n) { %> | ||
// If mocks is undefined, init it | ||
if (!VueTestUtils.config.mocks) { | ||
VueTestUtils.config.mocks = {}; | ||
if (!config.mocks) { | ||
config.mocks = {}; | ||
} | ||
// Mock i18n functions | ||
VueTestUtils.config.mocks.$t = (key: string) => key; | ||
VueTestUtils.config.mocks.$tc = (key: string) => key;<% } %> | ||
config.mocks.$t = (key: string) => key; | ||
config.mocks.$tc = (key: string) => key;<% } %> | ||
@@ -75,5 +77,5 @@ // Create empty router and export it | ||
* @param {VueClass} component The component to mount | ||
* @param {ShallowMountOptions|MountOptions} [options] The mount function options | ||
* @param {boolean} [fullMount] Use mount instead of shallowMount | ||
* @returns {VueTestUtils.Wrapper} The wrapper instance | ||
* @param {ShallowMountOptions|MountOptions} [options={}] The mount function options | ||
* @param {boolean} [fullMount=false] Use mount instead of shallowMount | ||
* @returns {Wrapper} The wrapper instance | ||
*/ | ||
@@ -84,3 +86,3 @@ export function mountComponent( | ||
fullMount: boolean = false | ||
): VueTestUtils.Wrapper<Vue> { | ||
): Wrapper<Vue> { | ||
// Use mount() instead of shallowMount() when fullMount is true | ||
@@ -87,0 +89,0 @@ const fn = fullMount ? mount : shallowMount; |
// Vue CLI configuration | ||
// see https://cli.vuejs.org/guide/ for help | ||
process.env.VUE_APP_VERSION = require('./package.json').version; | ||
module.exports = { | ||
@@ -4,0 +7,0 @@ configureWebpack: { |
const fixEnvFile = require('./fixEnvFile'); | ||
module.exports = (api) => { | ||
const { serve, build } = api.service.commands; | ||
const { serve } = api.service.commands; | ||
const serveFn = serve.fn; | ||
const buildFn = build.fn; | ||
@@ -9,0 +8,0 @@ // Augment serve command with fixEnvFile |
{ | ||
"name": "@cnamts/vue-cli-plugin-vue-dash", | ||
"version": "2.0.0-alpha.47", | ||
"version": "2.0.0-alpha.48", | ||
"description": "Vue CLI plugin to scaffold front-end projects", | ||
@@ -23,4 +23,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@cnamts/cli-helpers": "^2.0.0-alpha.47", | ||
"dayjs": "^1.8.19", | ||
"@cnamts/cli-helpers": "^2.0.0-alpha.48", | ||
"dayjs": "^1.8.20", | ||
"fs-extra": "^8.1.0", | ||
@@ -32,3 +32,3 @@ "superb": "^4.0.0" | ||
}, | ||
"gitHead": "ce7eda38f509a730aa7e1fb258201e5ffced3438" | ||
"gitHead": "e8321e6ec0e51c18a36909ab62446b2732ee019e" | ||
} |
@@ -0,1 +1,3 @@ | ||
const shouldRenderTemplate = require('./shouldRenderTemplate'); | ||
const Superb = require('superb'); | ||
@@ -6,3 +8,3 @@ | ||
module.exports = [ | ||
const prompts = [ | ||
{ | ||
@@ -27,1 +29,3 @@ name: 'description', | ||
]; | ||
module.exports = shouldRenderTemplate ? prompts : undefined; |
# Vue CLI plugin Vue Dash | ||
> Vue CLI plugin to scaffold front-end projects | ||
> Vue CLI plugin to scaffold CNAM front-end projects | ||
## Installation | ||
This plugin is not intended to be installed manually, but used via the Vue Dash preset. | ||
If you want to scaffold a new project, you should use the [Vue Dash Preset](https://github.com/assurance-maladie-digital/vue-cli-preset#readme). | ||
But if you want to add it to an existing project, you should install the plugin and then invoke it: | ||
```bash | ||
# Install the plugin | ||
yarn add -D @cnamts/vue-cli-plugin-vue-dash | ||
# Invoke it | ||
vue invoke @cnamts/vue-dash | ||
``` | ||
By default, this will not update your project files, but if you want to render the Vue Dash template anyway, you can use the `--render-template` option: | ||
```bash | ||
vue invoke @cnamts/vue-dash -- --render-template | ||
``` | ||
## Features | ||
This plugin contains the template to scaffold new projects, but also some extra features described below. | ||
### Auto fix missing env var file | ||
In our applications, there is env var files located in `public/js/config`. | ||
When cloning the project, you have two files: `config.js.env` and `config.js`. The first is used when deploying your project, and the later serves as a template to create the `config.js` file locally. | ||
This plugin augments the default `vue-cli-service serve` command by copying `config.js.dist` to `config.js` if the file doesn't exists. | ||
This way you have no setup to do when cloning a project! |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
180845
109
1692
37
6
Updateddayjs@^1.8.20