create-quasar 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/package.json +2 -4
  2. package/scripts/create-test-project.ts +1 -3
  3. package/templates/app/__eslint.config.js +0 -1
  4. package/templates/app/quasar-v2/create-quasar-script.js +4 -35
  5. package/templates/app/quasar-v2/js-vite-2/BASE/README.md +4 -4
  6. package/templates/app/quasar-v2/js-vite-2/BASE/_.vscode/extensions.json +2 -2
  7. package/templates/app/quasar-v2/js-vite-2/BASE/_.vscode/settings.json +2 -2
  8. package/templates/app/quasar-v2/js-vite-2/BASE/_package.json +11 -12
  9. package/templates/app/quasar-v2/js-vite-2/BASE/index.html +3 -3
  10. package/templates/app/quasar-v2/js-vite-2/BASE/quasar.config.js +9 -10
  11. package/templates/app/quasar-v2/js-vite-2/BASE/src/App.vue +0 -11
  12. package/templates/app/quasar-v2/js-vite-2/BASE/src/components/EssentialLink.vue +7 -35
  13. package/templates/app/quasar-v2/js-vite-2/BASE/src/layouts/MainLayout.vue +2 -141
  14. package/templates/app/quasar-v2/js-vite-2/BASE/src/pages/ErrorNotFound.vue +0 -11
  15. package/templates/app/quasar-v2/js-vite-2/BASE/src/pages/IndexPage.vue +0 -11
  16. package/templates/app/quasar-v2/js-vite-2/create-quasar-script.js +12 -4
  17. package/templates/app/quasar-v2/js-vite-2/eslint/_eslint.config.js +3 -3
  18. package/templates/app/quasar-v2/js-webpack-4/BASE/README.md +4 -4
  19. package/templates/app/quasar-v2/js-webpack-4/BASE/_.vscode/extensions.json +2 -2
  20. package/templates/app/quasar-v2/js-webpack-4/BASE/_.vscode/settings.json +2 -2
  21. package/templates/app/quasar-v2/js-webpack-4/BASE/_package.json +10 -11
  22. package/templates/app/quasar-v2/js-webpack-4/BASE/index.html +3 -3
  23. package/templates/app/quasar-v2/js-webpack-4/BASE/quasar.config.js +5 -6
  24. package/templates/app/quasar-v2/js-webpack-4/BASE/src/App.vue +0 -11
  25. package/templates/app/quasar-v2/js-webpack-4/BASE/src/components/EssentialLink.vue +7 -35
  26. package/templates/app/quasar-v2/js-webpack-4/BASE/src/layouts/MainLayout.vue +2 -141
  27. package/templates/app/quasar-v2/js-webpack-4/BASE/src/pages/ErrorNotFound.vue +0 -11
  28. package/templates/app/quasar-v2/js-webpack-4/BASE/src/pages/IndexPage.vue +0 -11
  29. package/templates/app/quasar-v2/js-webpack-4/create-quasar-script.js +12 -4
  30. package/templates/app/quasar-v2/js-webpack-4/eslint/_eslint.config.js +3 -3
  31. package/templates/app/quasar-v2/ts-vite-2/BASE/README.md +4 -4
  32. package/templates/app/quasar-v2/ts-vite-2/BASE/_.vscode/extensions.json +2 -2
  33. package/templates/app/quasar-v2/ts-vite-2/BASE/_.vscode/settings.json +2 -2
  34. package/templates/app/quasar-v2/ts-vite-2/BASE/_package.json +11 -12
  35. package/templates/app/quasar-v2/ts-vite-2/BASE/index.html +3 -3
  36. package/templates/app/quasar-v2/ts-vite-2/BASE/quasar.config.ts +9 -10
  37. package/templates/app/quasar-v2/ts-vite-2/BASE/src/App.vue +0 -11
  38. package/templates/app/quasar-v2/ts-vite-2/BASE/src/components/EssentialLink.vue +2 -37
  39. package/templates/app/quasar-v2/ts-vite-2/BASE/src/components/ExampleComponent.vue +2 -98
  40. package/templates/app/quasar-v2/ts-vite-2/BASE/src/layouts/MainLayout.vue +2 -141
  41. package/templates/app/quasar-v2/ts-vite-2/BASE/src/pages/ErrorNotFound.vue +0 -11
  42. package/templates/app/quasar-v2/ts-vite-2/BASE/src/pages/IndexPage.vue +2 -90
  43. package/templates/app/quasar-v2/ts-vite-2/__.eslintrc.cjs +0 -1
  44. package/templates/app/quasar-v2/ts-vite-2/create-quasar-script.js +12 -4
  45. package/templates/app/quasar-v2/ts-vite-2/eslint/_eslint.config.js +3 -3
  46. package/templates/app/quasar-v2/ts-vite-2/i18n/src/boot/i18n.ts +2 -2
  47. package/templates/app/quasar-v2/ts-webpack-4/BASE/README.md +4 -4
  48. package/templates/app/quasar-v2/ts-webpack-4/BASE/_.vscode/extensions.json +2 -2
  49. package/templates/app/quasar-v2/ts-webpack-4/BASE/_.vscode/settings.json +2 -2
  50. package/templates/app/quasar-v2/ts-webpack-4/BASE/_package.json +10 -11
  51. package/templates/app/quasar-v2/ts-webpack-4/BASE/index.html +3 -3
  52. package/templates/app/quasar-v2/ts-webpack-4/BASE/quasar.config.ts +5 -6
  53. package/templates/app/quasar-v2/ts-webpack-4/BASE/src/App.vue +0 -11
  54. package/templates/app/quasar-v2/ts-webpack-4/BASE/src/components/EssentialLink.vue +2 -37
  55. package/templates/app/quasar-v2/ts-webpack-4/BASE/src/components/ExampleComponent.vue +2 -98
  56. package/templates/app/quasar-v2/ts-webpack-4/BASE/src/layouts/MainLayout.vue +2 -141
  57. package/templates/app/quasar-v2/ts-webpack-4/BASE/src/pages/ErrorNotFound.vue +0 -11
  58. package/templates/app/quasar-v2/ts-webpack-4/BASE/src/pages/IndexPage.vue +2 -90
  59. package/templates/app/quasar-v2/ts-webpack-4/__.eslintrc.cjs +0 -1
  60. package/templates/app/quasar-v2/ts-webpack-4/create-quasar-script.js +12 -4
  61. package/templates/app/quasar-v2/ts-webpack-4/eslint/_eslint.config.js +3 -3
  62. package/templates/app/quasar-v2/ts-webpack-4/i18n/src/boot/i18n.ts +2 -2
  63. package/templates/app-extension/__eslint.config.js +1 -3
  64. package/templates/app-extension/ae-js/BASE/README.md +5 -5
  65. package/templates/app-extension/ae-js/BASE/_package.json +6 -6
  66. package/templates/app-extension/ae-js/BASE/src/index.js +1 -1
  67. package/templates/app-extension/ae-js/create-quasar-script.js +0 -15
  68. package/templates/app-extension/ae-js/install-script/src/install.js +1 -1
  69. package/templates/app-extension/ae-js/prompts-script/src/prompts.js +1 -1
  70. package/templates/app-extension/ae-js/uninstall-script/src/uninstall.js +1 -1
  71. package/templates/app-extension/ae-ts/BASE/README.md +6 -6
  72. package/templates/app-extension/ae-ts/BASE/_package.json +9 -9
  73. package/templates/app-extension/ae-ts/BASE/app-extension/README.md +7 -7
  74. package/templates/app-extension/ae-ts/BASE/app-extension/_package.json +9 -9
  75. package/templates/app-extension/ae-ts/BASE/app-extension/src/index.ts +2 -2
  76. package/templates/app-extension/ae-ts/BASE/app-extension/src/runtime/README.md +3 -3
  77. package/templates/app-extension/ae-ts/BASE/playground/quasar-cli-vite/README.md +11 -11
  78. package/templates/app-extension/ae-ts/BASE/playground/quasar-cli-vite/_package.json +4 -4
  79. package/templates/app-extension/ae-ts/BASE/playground/quasar-cli-vite/index.html +3 -3
  80. package/templates/app-extension/ae-ts/BASE/playground/quasar-cli-vite/quasar.extensions.json +1 -1
  81. package/templates/app-extension/ae-ts/BASE/playground/quasar-cli-vite/src/quasar.d.ts +1 -1
  82. package/templates/app-extension/ae-ts/BASE/playground/quasar-cli-webpack/README.md +10 -10
  83. package/templates/app-extension/ae-ts/BASE/playground/quasar-cli-webpack/_package.json +4 -4
  84. package/templates/app-extension/ae-ts/BASE/playground/quasar-cli-webpack/index.html +3 -3
  85. package/templates/app-extension/ae-ts/BASE/playground/quasar-cli-webpack/quasar.extensions.json +1 -1
  86. package/templates/app-extension/ae-ts/BASE/playground/quasar-cli-webpack/src/quasar.d.ts +1 -1
  87. package/templates/app-extension/create-quasar-script.js +1 -0
  88. package/templates/ui-kit/quasar-v2/BASE/LICENSE +1 -1
  89. package/templates/ui-kit/quasar-v2/BASE/README.md +4 -4
  90. package/templates/ui-kit/quasar-v2/BASE/ui/README.md +29 -29
  91. package/templates/ui-kit/quasar-v2/BASE/ui/_package.json +4 -4
  92. package/templates/ui-kit/quasar-v2/BASE/ui/build/index.js +1 -1
  93. package/templates/ui-kit/quasar-v2/BASE/ui/build/script.javascript.js +2 -2
  94. package/templates/ui-kit/quasar-v2/BASE/ui/dev/src/index.template.html +10 -5
  95. package/templates/ui-kit/quasar-v2/BASE/ui/dev/src/layouts/MyLayout.vue +1 -1
  96. package/templates/ui-kit/quasar-v2/BASE/ui/dev/src/pages/Test1.vue +4 -4
  97. package/templates/ui-kit/quasar-v2/BASE/ui/src/index.sass +2 -2
  98. package/templates/ui-kit/quasar-v2/BASE/ui/src/vue-plugin.js +6 -6
  99. package/templates/ui-kit/quasar-v2/BASE/ui/umd-test.html +2 -2
  100. package/templates/ui-kit/quasar-v2/ae/app-extension/README.md +6 -6
  101. package/templates/ui-kit/quasar-v2/ae/app-extension/_package.json +5 -5
  102. package/templates/ui-kit/quasar-v2/ae/app-extension/src/boot/register.js +1 -1
  103. package/templates/ui-kit/quasar-v2/ae/app-extension/src/index.js +7 -7
  104. package/templates/ui-kit/quasar-v2/ui-component/ui/src/components/Component.js +3 -3
  105. package/templates/ui-kit/quasar-v2/ui-component/ui/src/components/Component.sass +1 -1
  106. package/templates/ui-kit/quasar-v2/ui-directive/ui/src/directives/Directive.js +1 -1
  107. package/templates/ui-kit/quasar-v2/ui-directive/ui/src/directives/Directive.sass +1 -1
  108. package/utils/index.js +2 -6
  109. package/utils/template.js +280 -0
  110. package/templates/app/quasar-v2/js-vite-2/axios/src/boot/axios.js +0 -24
  111. package/templates/app/quasar-v2/js-vite-2/scss/src/css/app.scss +0 -1
  112. package/templates/app/quasar-v2/js-vite-2/scss/src/css/quasar.variables.scss +0 -25
  113. package/templates/app/quasar-v2/js-webpack-4/axios/src/boot/axios.js +0 -24
  114. package/templates/app/quasar-v2/js-webpack-4/scss/src/css/app.scss +0 -1
  115. package/templates/app/quasar-v2/js-webpack-4/scss/src/css/quasar.variables.scss +0 -25
  116. package/templates/app/quasar-v2/ts-vite-2/axios/src/boot/axios.ts +0 -31
  117. package/templates/app/quasar-v2/ts-vite-2/scss/src/css/app.scss +0 -1
  118. package/templates/app/quasar-v2/ts-vite-2/scss/src/css/quasar.variables.scss +0 -25
  119. package/templates/app/quasar-v2/ts-webpack-4/axios/src/boot/axios.ts +0 -31
  120. package/templates/app/quasar-v2/ts-webpack-4/scss/src/css/app.scss +0 -1
  121. package/templates/app/quasar-v2/ts-webpack-4/scss/src/css/quasar.variables.scss +0 -25
  122. package/test-project/.editorconfig +0 -7
  123. package/test-project/.prettierrc.json +0 -5
  124. package/test-project/.vscode/extensions.json +0 -15
  125. package/test-project/.vscode/settings.json +0 -9
  126. package/test-project/README.md +0 -43
  127. package/test-project/eslint.config.js +0 -83
  128. package/test-project/index.html +0 -24
  129. package/test-project/package.json +0 -45
  130. package/test-project/pnpm-lock.yaml +0 -5293
  131. package/test-project/pnpm-workspace.yaml +0 -6
  132. package/test-project/postcss.config.js +0 -29
  133. package/test-project/public/favicon.ico +0 -0
  134. package/test-project/public/icons/favicon-128x128.png +0 -0
  135. package/test-project/public/icons/favicon-16x16.png +0 -0
  136. package/test-project/public/icons/favicon-32x32.png +0 -0
  137. package/test-project/public/icons/favicon-96x96.png +0 -0
  138. package/test-project/quasar.config.ts +0 -217
  139. package/test-project/src/App.vue +0 -7
  140. package/test-project/src/assets/quasar-logo-vertical.svg +0 -15
  141. package/test-project/src/boot/.gitkeep +0 -0
  142. package/test-project/src/components/EssentialLink.vue +0 -27
  143. package/test-project/src/components/ExampleComponent.vue +0 -37
  144. package/test-project/src/components/models.ts +0 -8
  145. package/test-project/src/css/app.scss +0 -1
  146. package/test-project/src/css/quasar.variables.scss +0 -25
  147. package/test-project/src/env.d.ts +0 -7
  148. package/test-project/src/layouts/MainLayout.vue +0 -81
  149. package/test-project/src/pages/ErrorNotFound.vue +0 -23
  150. package/test-project/src/pages/IndexPage.vue +0 -43
  151. package/test-project/src/router/index.ts +0 -37
  152. package/test-project/src/router/routes.ts +0 -18
  153. package/test-project/tsconfig.json +0 -3
@@ -11,7 +11,7 @@
11
11
  />
12
12
 
13
13
  <q-toolbar-title>
14
- quasar-ui-<%= name %> v{{ version }}
14
+ quasar-ui-<%= scope.name %> v{{ version }}
15
15
  </q-toolbar-title>
16
16
 
17
17
  <div>Quasar v{{ $q.version }}</div>
@@ -1,10 +1,10 @@
1
1
  <template>
2
2
  <q-page padding>
3
- <% if (features.component) { %>
4
- <<%= componentName %> />
3
+ <% if (scope.features.component) { %>
4
+ <<%= scope.componentName %> />
5
5
  <% } %>
6
- <% if (features.directive) { %>
7
- <div v-<%= directiveName %> class="directive-target">
6
+ <% if (scope.features.directive) { %>
7
+ <div v-<%= scope.directiveName %> class="directive-target">
8
8
  x
9
9
  </div>
10
10
  <% } %>
@@ -1,7 +1,7 @@
1
1
  @import 'quasar/src/css/variables.sass'
2
- <% if (features.component) { %>
2
+ <% if (scope.features.component) { %>
3
3
  @import './components/Component.sass'
4
4
  <% } %>
5
- <% if (features.directive) { %>
5
+ <% if (scope.features.directive) { %>
6
6
  @import './directives/Directive.sass'
7
7
  <% } %>
@@ -1,16 +1,16 @@
1
- <% if (features.component) { %>import Component from './components/Component'<% } %>
2
- <% if (features.directive) { %>import Directive from './directives/Directive'<% } %>
1
+ <% if (scope.features.component) { %>import Component from './components/Component'<% } %>
2
+ <% if (scope.features.directive) { %>import Directive from './directives/Directive'<% } %>
3
3
 
4
4
  const version = __UI_VERSION__
5
5
 
6
6
  function install (app) {
7
- <% if (features.component) { %> app.component(Component.name, Component)<% } %>
8
- <% if (features.directive) { %> app.directive(Directive.name, Directive)<% } %>
7
+ <% if (scope.features.component) { %> app.component(Component.name, Component)<% } %>
8
+ <% if (scope.features.directive) { %> app.directive(Directive.name, Directive)<% } %>
9
9
  }
10
10
 
11
11
  export {
12
12
  version,
13
- <% if (features.component) { %> Component,<% } %>
14
- <% if (features.directive) { %> Directive,<% } %>
13
+ <% if (scope.features.component) { %> Component,<% } %>
14
+ <% if (scope.features.directive) { %> Directive,<% } %>
15
15
  install
16
16
  }
@@ -46,13 +46,13 @@
46
46
  const app = Vue.createApp({
47
47
  setup () {
48
48
  return {
49
- version: <%= umdExportName %>.version
49
+ version: <%= scope.umdExportName %>.version
50
50
  }
51
51
  }
52
52
  })
53
53
 
54
54
  app.use(Quasar)
55
- app.use(<%= umdExportName %>)
55
+ app.use(<%= scope.umdExportName %>)
56
56
  app.mount('#q-app')
57
57
  </script>
58
58
  </body>
@@ -1,13 +1,13 @@
1
- # Quasar App Extension <%= name %>
1
+ # Quasar App Extension <%= scope.name %>
2
2
 
3
3
  > Add a short description of your App Extension. What does it do? How is it beneficial? Why would someone want to use it?
4
4
 
5
- [![npm](https://img.shields.io/npm/v/quasar-app-extension-<%= name %>.svg?label=quasar-app-extension-<%= name %>)](https://www.npmjs.com/package/quasar-app-extension-<%= name %>)
6
- [![npm](https://img.shields.io/npm/dt/quasar-app-extension-<%= name %>.svg)](https://www.npmjs.com/package/quasar-app-extension-<%= name %>)
5
+ [![npm](https://img.shields.io/npm/v/quasar-app-extension-<%= scope.name %>.svg?label=quasar-app-extension-<%= scope.name %>)](https://www.npmjs.com/package/quasar-app-extension-<%= scope.name %>)
6
+ [![npm](https://img.shields.io/npm/dt/quasar-app-extension-<%= scope.name %>.svg)](https://www.npmjs.com/package/quasar-app-extension-<%= scope.name %>)
7
7
 
8
8
  # Install
9
9
  ```bash
10
- quasar ext add <%= name %>
10
+ quasar ext add <%= scope.name %>
11
11
  ```
12
12
  Quasar CLI will retrieve it from NPM and install the extension.
13
13
 
@@ -17,7 +17,7 @@ Quasar CLI will retrieve it from NPM and install the extension.
17
17
 
18
18
  # Uninstall
19
19
  ```bash
20
- quasar ext remove <%= name %>
20
+ quasar ext remove <%= scope.name %>
21
21
  ```
22
22
 
23
23
  # Info
@@ -30,4 +30,4 @@ quasar ext remove <%= name %>
30
30
  If you appreciate the work that went into this App Extension, please consider [donating to Quasar](https://donate.quasar.dev).
31
31
 
32
32
  # License
33
- <%= license %> (c) <%= author %>
33
+ <%= scope.license %> (c) <%= scope.author %>
@@ -1,12 +1,12 @@
1
1
  {
2
- "name": "quasar-app-extension-<%= name %>",
2
+ "name": "quasar-app-extension-<%= scope.name %>",
3
3
  "version": "0.0.1",
4
- "description": "<%= aeDescription %>",
5
- "author": "<%= author %>",
6
- "license": "<%= license %>",
4
+ "description": "<%= scope.aeDescription %>",
5
+ "author": "<%= scope.author %>",
6
+ "license": "<%= scope.license %>",
7
7
  "type": "module",
8
8
  "dependencies": {
9
- "quasar-ui-<%= name %>": "latest"
9
+ "quasar-ui-<%= scope.name %>": "latest"
10
10
  },
11
11
  "engines": {
12
12
  "node": ">= 8.9.0",
@@ -1,5 +1,5 @@
1
1
  import { boot } from 'quasar/wrappers'
2
- import VuePlugin from 'quasar-ui-<%= name %>'
2
+ import VuePlugin from 'quasar-ui-<%= scope.name %>'
3
3
 
4
4
  export default boot(({ app }) => {
5
5
  app.use(VuePlugin)
@@ -7,7 +7,7 @@
7
7
 
8
8
  function extendConf (conf, api) {
9
9
  // register our boot file
10
- conf.boot.push('~quasar-app-extension-<%= name %>/src/boot/register.js')
10
+ conf.boot.push('~quasar-app-extension-<%= scope.name %>/src/boot/register.js')
11
11
 
12
12
  if (api.hasWebpack) {
13
13
  // make sure app extension files & ui package gets transpiled
@@ -15,11 +15,11 @@ function extendConf (conf, api) {
15
15
  conf.build.webpackTranspileDependencies // q/app-webpack >= v4
16
16
  || conf.build.transpileDependencies // q/app-webpack v3
17
17
  )
18
- transpileTarget.push(/quasar-app-extension-<%= name %>[\\/]src/)
18
+ transpileTarget.push(/quasar-app-extension-<%= scope.name %>[\\/]src/)
19
19
  }
20
20
 
21
21
  // make sure the stylesheet goes through webpack to avoid SSR issues
22
- conf.css.push('~quasar-ui-<%= name %>/src/index.sass')
22
+ conf.css.push('~quasar-ui-<%= scope.name %>/src/index.sass')
23
23
  }
24
24
 
25
25
  export default function (api) {
@@ -35,12 +35,12 @@ export default function (api) {
35
35
  api.compatibleWith('@quasar/app-webpack', '^3.10.0 || ^4.0.0')
36
36
  }
37
37
 
38
- <% if (features.component) { %>
38
+ <% if (scope.features.component) { %>
39
39
  // Uncomment the line below if you provide a JSON API for your component
40
- // api.registerDescribeApi('<%= componentName %>', '~quasar-ui-<%= name %>/src/components/<%= componentName %>.json')
41
- <% } %><% if (features.directive) { %>
40
+ // api.registerDescribeApi('<%= scope.componentName %>', '~quasar-ui-<%= scope.name %>/src/components/<%= scope.componentName %>.json')
41
+ <% } %><% if (scope.features.directive) { %>
42
42
  // Uncomment the line below if you provide a JSON API for your directive
43
- // api.registerDescribeApi('<%= directiveName %>', '~quasar-ui-<%= name %>/src/directives/<%= directiveName %>.json')
43
+ // api.registerDescribeApi('<%= scope.directiveName %>', '~quasar-ui-<%= scope.name %>/src/directives/<%= scope.directiveName %>.json')
44
44
  <% } %>
45
45
 
46
46
  // We extend /quasar.conf.js
@@ -2,12 +2,12 @@ import { h } from 'vue'
2
2
  import { QBadge } from 'quasar'
3
3
 
4
4
  export default {
5
- name: '<%= componentName %>',
5
+ name: '<%= scope.componentName %>',
6
6
 
7
7
  setup () {
8
8
  return () => h(QBadge, {
9
- class: '<%= componentName %>',
10
- label: '<%= componentName %>'
9
+ class: '<%= scope.componentName %>',
10
+ label: '<%= scope.componentName %>'
11
11
  })
12
12
  }
13
13
  }
@@ -1,2 +1,2 @@
1
- .<%= componentName %>
1
+ .<%= scope.componentName %>
2
2
  font-weight: bold
@@ -1,5 +1,5 @@
1
1
  export default {
2
- name: '<%= directiveName %>',
2
+ name: '<%= scope.directiveName %>',
3
3
 
4
4
  mounted (_el) {
5
5
  //
@@ -1,2 +1,2 @@
1
- .<%= directiveName %>
1
+ .<%= scope.directiveName %>
2
2
  font-size: 14px
package/utils/index.js CHANGED
@@ -3,7 +3,6 @@ import { fileURLToPath } from 'node:url'
3
3
  import { sep, dirname, normalize, join, resolve, extname } from 'node:path'
4
4
  import { execSync as exec } from 'node:child_process'
5
5
  import { sync as spawnSync } from 'cross-spawn'
6
-
7
6
  import {
8
7
  emptyDirSync,
9
8
  ensureDirSync,
@@ -11,10 +10,10 @@ import {
11
10
  copySync
12
11
  } from 'fs-extra/esm'
13
12
  import promptUser from 'prompts'
14
- import compileTemplate from 'lodash/template.js'
15
13
  import { globSync } from 'tinyglobby'
16
14
  import { yellow, green } from 'kolorist'
17
15
 
16
+ import { renderTemplate as renderTemplateFn } from './template.js'
18
17
  import logger from './logger.js'
19
18
 
20
19
  const TEMPLATING_FILE_EXTENSIONS = [
@@ -103,11 +102,8 @@ function renderTemplate(relativePath, scope) {
103
102
 
104
103
  if (TEMPLATING_FILE_EXTENSIONS.includes(extension)) {
105
104
  const rawContent = readFileSync(sourcePath, 'utf-8')
106
- const template = compileTemplate(rawContent, {
107
- interpolate: /<%=([\s\S]+?)%>/g
108
- })
109
105
 
110
- let newContent = template(scope)
106
+ let newContent = renderTemplateFn(rawContent, scope)
111
107
  if (extension === '.json') {
112
108
  try {
113
109
  // try to format the JSON
@@ -0,0 +1,280 @@
1
+ /**
2
+ * Heavily inspired by Eta v4.5.1
3
+ */
4
+
5
+ const fnAccumulator = '__qstr__'
6
+ const defaultParseOptions = {
7
+ varName: 'scope',
8
+ exec: '', // never '-' | '_'
9
+ interpolate: '=', // never '-' | '_'
10
+ raw: '~', // never '-' | '_'
11
+ header: '',
12
+ tagStart: '<%',
13
+ tagEnd: '%>'
14
+ }
15
+
16
+ const newlineRE = /\n/
17
+ const newlineTrimRE = /^(?:\r\n|\n|\r)/
18
+ const escapeRegexpRE = /[.*+\-?^${}()|[\]\\]/g
19
+ const templateLitReg =
20
+ /`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g
21
+ const singleQuoteReg = /'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g
22
+ const doubleQuoteReg = /"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g
23
+
24
+ function throwParseError(message, str, index) {
25
+ const whitespace = str.slice(0, index).split(newlineRE)
26
+
27
+ const lineNo = whitespace.length
28
+ const colNo = whitespace[lineNo - 1].length + 1
29
+
30
+ message +=
31
+ ' at line ' +
32
+ lineNo +
33
+ ' col ' +
34
+ colNo +
35
+ ':\n\n' +
36
+ ' ' +
37
+ str.split(newlineRE)[lineNo - 1] +
38
+ '\n' +
39
+ ' ' +
40
+ Array(colNo).join(' ') +
41
+ '^'
42
+
43
+ throw new Error(message)
44
+ }
45
+
46
+ function escapeRegExp(str) {
47
+ // From MDN
48
+ return str.replace(escapeRegexpRE, '\\$&') // $& means the whole matched string
49
+ }
50
+
51
+ function trimWS(str, wsLeft, wsRight) {
52
+ // Slightly confusing,
53
+ // but _}} will trim the left side of the following string
54
+ let leftTrim = wsLeft || wsLeft === false ? wsLeft : 'nl'
55
+ let rightTrim = wsRight || wsRight === false ? wsRight : false
56
+
57
+ if (!rightTrim && !leftTrim) return str
58
+
59
+ if (leftTrim === 'slurp' && rightTrim === 'slurp') {
60
+ return str.trim()
61
+ }
62
+
63
+ if (leftTrim === '_' || leftTrim === 'slurp') {
64
+ // full slurp
65
+ str = str.trimStart()
66
+ } else if (leftTrim === '-' || leftTrim === 'nl') {
67
+ // nl trim
68
+ str = str.replace(newlineTrimRE, '')
69
+ }
70
+
71
+ if (rightTrim === '_' || rightTrim === 'slurp') {
72
+ // full slurp
73
+ str = str.trimEnd()
74
+ } else if (rightTrim === '-' || rightTrim === 'nl') {
75
+ // nl trim
76
+ str = str.replace(newlineTrimRE, '')
77
+ }
78
+
79
+ return str
80
+ }
81
+
82
+ // opts: { exec, interpolate, raw, tagStart, tagEnd }
83
+ function getAST(str, opts) {
84
+ let ast = []
85
+ let trimLeftOfNextStr = false
86
+ let lastIndex = 0
87
+
88
+ templateLitReg.lastIndex = 0
89
+ singleQuoteReg.lastIndex = 0
90
+ doubleQuoteReg.lastIndex = 0
91
+
92
+ function pushString(strng, shouldTrimRightOfString) {
93
+ if (strng) {
94
+ // if string is truthy it must be of type 'string'
95
+
96
+ strng = trimWS(
97
+ strng,
98
+ trimLeftOfNextStr, // this will only be false on the first str, the next ones will be null or undefined
99
+ shouldTrimRightOfString
100
+ )
101
+
102
+ if (strng) {
103
+ // replace \ with \\, ' with \'
104
+ // we're going to convert all CRLF to LF so it doesn't take more than one replace
105
+
106
+ strng = strng.replace(/\\|'/g, '\\$&').replace(/\r\n|\n|\r/g, '\\n')
107
+
108
+ ast.push(strng)
109
+ }
110
+ }
111
+ }
112
+
113
+ const prefixes = [opts.exec, opts.interpolate, opts.raw].reduce(
114
+ (accumulator, prefix) => {
115
+ if (accumulator && prefix) {
116
+ return accumulator + '|' + escapeRegExp(prefix)
117
+ } else if (prefix) {
118
+ // accumulator is falsy
119
+ return escapeRegExp(prefix)
120
+ } else {
121
+ // prefix and accumulator are both falsy
122
+ return accumulator
123
+ }
124
+ },
125
+ ''
126
+ )
127
+
128
+ const parseOpenReg = new RegExp(
129
+ escapeRegExp(opts.tagStart) + '(-|_)?\\s*(' + prefixes + ')?\\s*',
130
+ 'g'
131
+ )
132
+
133
+ const parseCloseReg = new RegExp(
134
+ '\'|"|`|\\/\\*|(\\s*(-|_)?' + escapeRegExp(opts.tagEnd) + ')',
135
+ 'g'
136
+ )
137
+
138
+ let m
139
+
140
+ while ((m = parseOpenReg.exec(str))) {
141
+ const precedingString = str.slice(lastIndex, m.index)
142
+
143
+ lastIndex = m[0].length + m.index
144
+
145
+ const wsLeft = m[1]
146
+ const prefix = m[2] || '' // by default either ~, =, or empty
147
+
148
+ pushString(precedingString, wsLeft)
149
+
150
+ parseCloseReg.lastIndex = lastIndex
151
+ let closeTag
152
+ let currentObj = false
153
+
154
+ while ((closeTag = parseCloseReg.exec(str))) {
155
+ if (closeTag[1]) {
156
+ const content = str.slice(lastIndex, closeTag.index)
157
+
158
+ parseOpenReg.lastIndex = lastIndex = parseCloseReg.lastIndex
159
+
160
+ trimLeftOfNextStr = closeTag[2]
161
+
162
+ const currentType =
163
+ prefix === opts.exec
164
+ ? 'e'
165
+ : prefix === opts.raw
166
+ ? 'r'
167
+ : prefix === opts.interpolate
168
+ ? 'i'
169
+ : ''
170
+
171
+ currentObj = { t: currentType, val: content }
172
+ break
173
+ } else {
174
+ const char = closeTag[0]
175
+ if (char === '/*') {
176
+ const commentCloseInd = str.indexOf('*/', parseCloseReg.lastIndex)
177
+
178
+ if (commentCloseInd === -1) {
179
+ throwParseError('unclosed comment', str, closeTag.index)
180
+ }
181
+ parseCloseReg.lastIndex = commentCloseInd
182
+ } else if (char === "'") {
183
+ singleQuoteReg.lastIndex = closeTag.index
184
+
185
+ const singleQuoteMatch = singleQuoteReg.exec(str)
186
+ if (singleQuoteMatch) {
187
+ parseCloseReg.lastIndex = singleQuoteReg.lastIndex
188
+ } else {
189
+ throwParseError('unclosed string', str, closeTag.index)
190
+ }
191
+ } else if (char === '"') {
192
+ doubleQuoteReg.lastIndex = closeTag.index
193
+ const doubleQuoteMatch = doubleQuoteReg.exec(str)
194
+
195
+ if (doubleQuoteMatch) {
196
+ parseCloseReg.lastIndex = doubleQuoteReg.lastIndex
197
+ } else {
198
+ throwParseError('unclosed string', str, closeTag.index)
199
+ }
200
+ } else if (char === '`') {
201
+ templateLitReg.lastIndex = closeTag.index
202
+ const templateLitMatch = templateLitReg.exec(str)
203
+ if (templateLitMatch) {
204
+ parseCloseReg.lastIndex = templateLitReg.lastIndex
205
+ } else {
206
+ throwParseError('unclosed string', str, closeTag.index)
207
+ }
208
+ }
209
+ }
210
+ }
211
+ if (currentObj) {
212
+ ast.push(currentObj)
213
+ } else {
214
+ throwParseError('unclosed tag', str, m.index)
215
+ }
216
+ }
217
+
218
+ pushString(str.slice(lastIndex, str.length), false)
219
+ return ast
220
+ }
221
+
222
+ // opts: { varName, header }
223
+ function compileBody(ast, opts) {
224
+ let i = 0
225
+ const astLength = ast.length
226
+ let returnStr = `${opts.header}\nlet ${fnAccumulator} = '';\n`
227
+
228
+ for (; i < astLength; i++) {
229
+ const currentBlock = ast[i]
230
+
231
+ if (typeof currentBlock === 'string') {
232
+ returnStr += `${fnAccumulator}+='${currentBlock}';\n`
233
+ continue
234
+ }
235
+
236
+ const type = currentBlock.t // "r", "e", or "i"
237
+ let content = currentBlock.val || ''
238
+
239
+ if (type === 'r') {
240
+ // raw
241
+ returnStr += `${fnAccumulator}+=${content};\n`
242
+ } else if (type === 'i') {
243
+ // interpolate
244
+ returnStr += `${fnAccumulator}+=${content};\n`
245
+ } else if (type === 'e') {
246
+ // execute
247
+ returnStr += content + '\n'
248
+ }
249
+ }
250
+
251
+ return returnStr + `\nreturn ${fnAccumulator};`
252
+ }
253
+
254
+ export function compileTemplateToFile(str, rawOpts = {}) {
255
+ const opts = { ...defaultParseOptions, ...rawOpts }
256
+ const ast = getAST(str, opts)
257
+ const body = compileBody(ast, opts)
258
+ return `export default ${opts.varName} => {\n${body}\n}`
259
+ }
260
+
261
+ export function compileTemplateToFn(str, rawOpts = {}) {
262
+ const opts = { ...defaultParseOptions, ...rawOpts }
263
+ const ast = getAST(str, opts)
264
+ const body = compileBody(ast, opts)
265
+ return new Function(opts.varName, body)
266
+ }
267
+
268
+ export function renderTemplate(str, scope, rawOpts) {
269
+ let opts = rawOpts
270
+ if (opts?.varName === false) {
271
+ opts.varName = defaultParseOptions.varName
272
+ const keys = Object.keys(scope)
273
+ if (keys.length !== 0) {
274
+ opts.header = `const { ${keys.join(', ')} } = ${defaultParseOptions.varName}`
275
+ }
276
+ }
277
+
278
+ const templateFn = compileTemplateToFn(str, opts)
279
+ return templateFn(scope)
280
+ }
@@ -1,24 +0,0 @@
1
- import { defineBoot } from '#q-app/wrappers'
2
- import axios from 'axios'
3
-
4
- // Be careful when using SSR for cross-request state pollution
5
- // due to creating a Singleton instance here;
6
- // If any client changes this (global) instance, it might be a
7
- // good idea to move this instance creation inside of the
8
- // "export default () => {}" function below (which runs individually
9
- // for each client)
10
- const api = axios.create({ baseURL: 'https://api.example.com' })
11
-
12
- export default defineBoot(({ app }) => {
13
- // for use inside Vue files (Options API) through this.$axios and this.$api
14
-
15
- app.config.globalProperties.$axios = axios
16
- // ^ ^ ^ this will allow you to use this.$axios (for Vue Options API form)
17
- // so you won't necessarily have to import axios in each vue file
18
-
19
- app.config.globalProperties.$api = api
20
- // ^ ^ ^ this will allow you to use this.$api (for Vue Options API form)
21
- // so you can easily perform requests against your app's API
22
- })
23
-
24
- export { api }
@@ -1 +0,0 @@
1
- // app global css in SCSS form
@@ -1,25 +0,0 @@
1
- // Quasar SCSS (& Sass) Variables
2
- // --------------------------------------------------
3
- // To customize the look and feel of this app, you can override
4
- // the Sass/SCSS variables found in Quasar's source Sass/SCSS files.
5
-
6
- // Check documentation for full list of Quasar variables
7
-
8
- // Your own variables (that are declared here) and Quasar's own
9
- // ones will be available out of the box in your .vue/.scss/.sass files
10
-
11
- // It's highly recommended to change the default colors
12
- // to match your app's branding.
13
- // Tip: Use the "Theme Builder" on Quasar's documentation website.
14
-
15
- $primary : #1976D2;
16
- $secondary : #26A69A;
17
- $accent : #9C27B0;
18
-
19
- $dark : #1D1D1D;
20
- $dark-page : #121212;
21
-
22
- $positive : #21BA45;
23
- $negative : #C10015;
24
- $info : #31CCEC;
25
- $warning : #F2C037;
@@ -1,24 +0,0 @@
1
- import { defineBoot } from '#q-app/wrappers'
2
- import axios from 'axios'
3
-
4
- // Be careful when using SSR for cross-request state pollution
5
- // due to creating a Singleton instance here;
6
- // If any client changes this (global) instance, it might be a
7
- // good idea to move this instance creation inside of the
8
- // "export default () => {}" function below (which runs individually
9
- // for each client)
10
- const api = axios.create({ baseURL: 'https://api.example.com' })
11
-
12
- export default defineBoot(({ app }) => {
13
- // for use inside Vue files (Options API) through this.$axios and this.$api
14
-
15
- app.config.globalProperties.$axios = axios
16
- // ^ ^ ^ this will allow you to use this.$axios (for Vue Options API form)
17
- // so you won't necessarily have to import axios in each vue file
18
-
19
- app.config.globalProperties.$api = api
20
- // ^ ^ ^ this will allow you to use this.$api (for Vue Options API form)
21
- // so you can easily perform requests against your app's API
22
- })
23
-
24
- export { api }
@@ -1 +0,0 @@
1
- // app global css in SCSS form
@@ -1,25 +0,0 @@
1
- // Quasar SCSS (& Sass) Variables
2
- // --------------------------------------------------
3
- // To customize the look and feel of this app, you can override
4
- // the Sass/SCSS variables found in Quasar's source Sass/SCSS files.
5
-
6
- // Check documentation for full list of Quasar variables
7
-
8
- // Your own variables (that are declared here) and Quasar's own
9
- // ones will be available out of the box in your .vue/.scss/.sass files
10
-
11
- // It's highly recommended to change the default colors
12
- // to match your app's branding.
13
- // Tip: Use the "Theme Builder" on Quasar's documentation website.
14
-
15
- $primary : #1976D2;
16
- $secondary : #26A69A;
17
- $accent : #9C27B0;
18
-
19
- $dark : #1D1D1D;
20
- $dark-page : #121212;
21
-
22
- $positive : #21BA45;
23
- $negative : #C10015;
24
- $info : #31CCEC;
25
- $warning : #F2C037;
@@ -1,31 +0,0 @@
1
- import { defineBoot } from '#q-app/wrappers';
2
- import axios, { type AxiosInstance } from 'axios';
3
-
4
- declare module 'vue' {
5
- interface ComponentCustomProperties {
6
- $axios: AxiosInstance;
7
- $api: AxiosInstance;
8
- }
9
- }
10
-
11
- // Be careful when using SSR for cross-request state pollution
12
- // due to creating a Singleton instance here;
13
- // If any client changes this (global) instance, it might be a
14
- // good idea to move this instance creation inside of the
15
- // "export default () => {}" function below (which runs individually
16
- // for each client)
17
- const api = axios.create({ baseURL: 'https://api.example.com' });
18
-
19
- export default defineBoot(({ app }) => {
20
- // for use inside Vue files (Options API) through this.$axios and this.$api
21
-
22
- app.config.globalProperties.$axios = axios;
23
- // ^ ^ ^ this will allow you to use this.$axios (for Vue Options API form)
24
- // so you won't necessarily have to import axios in each vue file
25
-
26
- app.config.globalProperties.$api = api;
27
- // ^ ^ ^ this will allow you to use this.$api (for Vue Options API form)
28
- // so you can easily perform requests against your app's API
29
- });
30
-
31
- export { api };
@@ -1 +0,0 @@
1
- // app global css in SCSS form