diff --git a/messages/ui-bundle.generate.md b/messages/ui-bundle.generate.md index d952cfac..c726ab91 100644 --- a/messages/ui-bundle.generate.md +++ b/messages/ui-bundle.generate.md @@ -24,6 +24,10 @@ Use the --template flag for generating the files to get started with a specific <%= config.bin %> <%= command.id %> --name MyAngularApp --template angularbasic +- Generate a Vue-based UI bundle: + + <%= config.bin %> <%= command.id %> --name MyVueApp --template vuebasic + - Generate the React-based UI bundle in the "force-app/main/default/uiBundles" directory: <%= config.bin %> <%= command.id %> --name MyUiBundle --template reactbasic --output-dir force-app/main/default/uiBundles diff --git a/package.json b/package.json index ed19bdcd..ae1facfc 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "dependencies": { "@salesforce/core": "^9.2.0", "@salesforce/sf-plugins-core": "^13.0.5", - "@salesforce/templates": "^66.16.0" + "@salesforce/templates": "^66.17.2" }, "devDependencies": { "@oclif/plugin-command-snapshot": "^6.0.0", diff --git a/src/commands/template/generate/ui-bundle/index.ts b/src/commands/template/generate/ui-bundle/index.ts index 69e94da1..f3489082 100644 --- a/src/commands/template/generate/ui-bundle/index.ts +++ b/src/commands/template/generate/ui-bundle/index.ts @@ -43,7 +43,7 @@ export default class UiBundleGenerate extends SfCommand { summary: messages.getMessage('flags.template.summary'), description: messages.getMessage('flags.template.description'), default: 'default', - options: ['default', 'reactbasic', 'angularbasic'], + options: ['default', 'reactbasic', 'angularbasic', 'vuebasic'], }), label: Flags.string({ char: 'l', diff --git a/test/commands/template/generate/analytics/template.nut.ts b/test/commands/template/generate/analytics/template.nut.ts index 7761d206..a74ebed8 100644 --- a/test/commands/template/generate/analytics/template.nut.ts +++ b/test/commands/template/generate/analytics/template.nut.ts @@ -57,7 +57,6 @@ describe('template generate analytics template:', () => { name: 'fooDashboard_tp', state: { widgets: { - text_1: { parameters: { content: { diff --git a/test/commands/template/generate/ui-bundle/index.nut.ts b/test/commands/template/generate/ui-bundle/index.nut.ts index 59a39a80..c272b8f6 100644 --- a/test/commands/template/generate/ui-bundle/index.nut.ts +++ b/test/commands/template/generate/ui-bundle/index.nut.ts @@ -203,6 +203,57 @@ describe('template generate ui-bundle:', () => { }); }); + describe('Check UI bundle creation with vuebasic template', () => { + afterEach(() => { + const rootGraphqlrc = path.join(projectDir, '.graphqlrc.yml'); + if (fs.existsSync(rootGraphqlrc)) { + fs.unlinkSync(rootGraphqlrc); + } + }); + + it('should create Vue UI bundle with all required files and create .graphqlrc.yml at the project root', () => { + const outputDir = path.join(projectDir, 'force-app', 'main', 'default', UI_BUNDLES_DIR); + const firstResult = execCmd( + `template generate ui-bundle --name MyVueApp --template vuebasic --output-dir "${outputDir}"`, + { + ensureExitCode: 0, + } + ); + assert.file([ + path.join(outputDir, 'MyVueApp', 'MyVueApp.uibundle-meta.xml'), + path.join(outputDir, 'MyVueApp', 'index.html'), + path.join(outputDir, 'MyVueApp', 'ui-bundle.json'), + path.join(outputDir, 'MyVueApp', 'package.json'), + ]); + + const rootGraphqlrc = path.join(projectDir, '.graphqlrc.yml'); + assert.file(rootGraphqlrc); + assert.fileContent(rootGraphqlrc, "schema: 'schema.graphql'"); + assert.fileContent(rootGraphqlrc, "documents: './**/src/**/*.{graphql,js,ts,jsx,tsx}'"); + expect(firstResult.shellOutput.stdout).to.contain('create .graphqlrc.yml'); + + const contentBefore = fs.readFileSync(rootGraphqlrc, 'utf8'); + const mtimeBefore = fs.statSync(rootGraphqlrc).mtimeMs; + + const secondResult = execCmd( + `template generate ui-bundle --name MyVueApp2 --template vuebasic --output-dir "${outputDir}"`, + { + ensureExitCode: 0, + } + ); + assert.file([ + path.join(outputDir, 'MyVueApp2', 'MyVueApp2.uibundle-meta.xml'), + path.join(outputDir, 'MyVueApp2', 'package.json'), + ]); + expect(secondResult.shellOutput.stdout).to.not.contain('create .graphqlrc.yml'); + + const contentAfter = fs.readFileSync(rootGraphqlrc, 'utf8'); + const mtimeAfter = fs.statSync(rootGraphqlrc).mtimeMs; + expect(contentAfter).to.equal(contentBefore); + expect(mtimeAfter).to.equal(mtimeBefore); + }); + }); + describe('Check that all invalid name errors are thrown', () => { it('should throw a missing name error', () => { const stderr = execCmd('template generate ui-bundle').shellOutput.stderr; diff --git a/yarn.lock b/yarn.lock index af1d80fb..a5425792 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1408,10 +1408,10 @@ cli-progress "^3.12.0" terminal-link "^3.0.0" -"@salesforce/templates@^66.16.0": - version "66.16.0" - resolved "https://registry.yarnpkg.com/@salesforce/templates/-/templates-66.16.0.tgz#afe4e928334cd4553ce93b20957fb186c14de6ec" - integrity sha512-eJyqw9x0gAIl+rhKKeyOJ0lmQrYSHaz932EErn84pugewSYUjvomTgDUjKHqUrqgJA4yOciav8lQ/gkK2sC3AQ== +"@salesforce/templates@^66.17.2": + version "66.17.2" + resolved "https://registry.yarnpkg.com/@salesforce/templates/-/templates-66.17.2.tgz#ba615bc3f2195c93ac5f3f8feaeccb512236914e" + integrity sha512-6TU/NHWVPIgjG4FDwrJ3En+1n3OFRVTEkwWPyh6JSR7LkH/Iwmi1kuHyrHVNi8m0TCJZxBxNrZ2qdrL9CJuOIw== dependencies: "@salesforce/kit" "^4.0.0" ejs "^3.1.10"