@dative-gpi/foundation-shared-loader 0.0.2 → 0.0.5

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.
@@ -1,4 +1,4 @@
1
- export declare function generateImports(source: string): {
1
+ export declare function generateImports(source: string, skipShared: boolean, skipCore: boolean, skipAdmin: boolean, skipExtension: boolean): {
2
2
  code: string;
3
3
  source: string;
4
4
  };
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateImports = void 0;
4
4
  const getImports_1 = require("./getImports");
5
- function generateImports(source) {
6
- const { imports, components, directives } = (0, getImports_1.getImports)(source);
5
+ function generateImports(source, skipShared, skipCore, skipAdmin, skipExtension) {
6
+ const { imports, components, directives } = (0, getImports_1.getImports)(source, skipShared, skipCore, skipAdmin, skipExtension);
7
7
  let code = '';
8
8
  if (components.length || directives.length) {
9
9
  code += '\n\n/* Foundation */\n';
@@ -1,5 +1,5 @@
1
1
  import { type TemplateMatch } from './parseTemplate';
2
- export declare function getImports(source: string): {
2
+ export declare function getImports(source: string, skipShared: boolean, skipCore: boolean, skipAdmin: boolean, skipExtension: boolean): {
3
3
  imports: Map<string, string[]>;
4
4
  components: TemplateMatch[];
5
5
  directives: TemplateMatch[];
@@ -25,28 +25,33 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.getImports = void 0;
27
27
  const parseTemplate_1 = require("./parseTemplate");
28
- const sharedImportMap = __importStar(require("@dative-gpi/foundation-shared-components/importMap.json"));
29
- const coreImportMap = __importStar(require("@dative-gpi/foundation-core-components/importMap.json"));
30
- const adminImportMap = __importStar(require("@dative-gpi/foundation-admin-components/importMap.json"));
31
- function getImports(source) {
28
+ const sharedImportMap = __importStar(require("./mapping/foundation-shared-components-imports-map.json"));
29
+ const coreImportMap = __importStar(require("./mapping/foundation-core-components-imports-map.json"));
30
+ const adminImportMap = __importStar(require("./mapping/foundation-admin-components-imports-map.json"));
31
+ const extensionImportMap = __importStar(require("./mapping/foundation-extension-components-imports-map.json"));
32
+ function getImports(source, skipShared, skipCore, skipAdmin, skipExtension) {
32
33
  const { components, directives } = (0, parseTemplate_1.parseTemplate)(source);
33
34
  const resolvedComponents = [];
34
35
  const resolvedDirectives = [];
35
36
  const imports = new Map();
36
37
  if (components.size || directives.size) {
37
38
  components.forEach(component => {
38
- if (component.name in sharedImportMap.components) {
39
+ if (!skipShared && component.name in sharedImportMap.components) {
39
40
  resolvedComponents.push(component);
40
41
  addImport(imports, component.name, component.symbol, sharedImportMap.components[component.name].from);
41
42
  }
42
- else if (component.name in coreImportMap.components) {
43
+ else if (!skipCore && component.name in coreImportMap.components) {
43
44
  resolvedComponents.push(component);
44
45
  addImport(imports, component.name, component.symbol, coreImportMap.components[component.name].from);
45
46
  }
46
- else if (component.name in adminImportMap.components) {
47
+ else if (!skipAdmin && component.name in adminImportMap.components) {
47
48
  resolvedComponents.push(component);
48
49
  addImport(imports, component.name, component.symbol, adminImportMap.components[component.name].from);
49
50
  }
51
+ else if (!skipExtension && component.name in extensionImportMap.components) {
52
+ resolvedComponents.push(component);
53
+ addImport(imports, component.name, component.symbol, extensionImportMap.components[component.name].from);
54
+ }
50
55
  });
51
56
  // directives.forEach(directive => {
52
57
  // if (importMap.directives.includes(directive.name)) {
@@ -1,2 +1,2 @@
1
1
  import type { Plugin } from 'vite';
2
- export declare function importPlugin(): Plugin;
2
+ export declare function importPlugin(skipShared: boolean, skipCore: boolean, skipAdmin: boolean, skipExtension: boolean): Plugin;
@@ -11,7 +11,7 @@ function parseId(id) {
11
11
  path: pathname ?? id
12
12
  };
13
13
  }
14
- function importPlugin() {
14
+ function importPlugin(skipShared, skipCore, skipAdmin, skipExtension) {
15
15
  return {
16
16
  name: 'foundation:import',
17
17
  configResolved(config) {
@@ -23,7 +23,7 @@ function importPlugin() {
23
23
  const { query, path } = parseId(id);
24
24
  if (((!query || !('vue' in query)) && (0, path_1.extname)(path) === '.vue' && !/^import { render as _sfc_render } from ".*"$/m.test(code)) ||
25
25
  (query && 'vue' in query && (query.type === 'template' || (query.type === 'script' && query.setup === 'true')))) {
26
- const { code: imports, source } = (0, generateImports_1.generateImports)(code);
26
+ const { code: imports, source } = (0, generateImports_1.generateImports)(code, skipShared, skipCore, skipAdmin, skipExtension);
27
27
  return {
28
28
  code: source + imports,
29
29
  map: null,
package/dist/index.d.ts CHANGED
@@ -1,3 +1,8 @@
1
1
  import { Plugin } from 'vite';
2
- declare function FoundationSharedAutoImport(): Plugin[];
2
+ declare function FoundationSharedAutoImport({ skipShared, skipCore, skipAdmin, skipExtension }?: {
3
+ skipShared?: boolean;
4
+ skipCore?: boolean;
5
+ skipAdmin?: boolean;
6
+ skipExtension?: boolean;
7
+ }): Plugin[];
3
8
  export default FoundationSharedAutoImport;
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const importPlugin_1 = require("./importPlugin");
4
- function FoundationSharedAutoImport() {
4
+ function FoundationSharedAutoImport({ skipShared = false, skipCore = false, skipAdmin = false, skipExtension = false } = {}) {
5
5
  const plugins = [];
6
- plugins.push((0, importPlugin_1.importPlugin)());
6
+ plugins.push((0, importPlugin_1.importPlugin)(skipShared, skipCore, skipAdmin, skipExtension));
7
7
  return plugins;
8
8
  }
9
9
  module.exports = FoundationSharedAutoImport;
@@ -0,0 +1,4 @@
1
+ {
2
+ "components": {},
3
+ "directives": []
4
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "components": {
3
+ "FSCoreButton": {
4
+ "from": "@dative-gpi/foundation-core-components/components/FSCoreButton.vue"
5
+ }
6
+ },
7
+ "directives": []
8
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "components": {},
3
+ "directives": []
4
+ }
@@ -0,0 +1,65 @@
1
+ {
2
+ "components": {
3
+ "FSWindow": {
4
+ "from": "@dative-gpi/foundation-shared-components/components/FSWindow.vue"
5
+ },
6
+ "FSSpan": {
7
+ "from": "@dative-gpi/foundation-shared-components/components/FSSpan.vue"
8
+ },
9
+ "FSSlideGroup": {
10
+ "from": "@dative-gpi/foundation-shared-components/components/FSSlideGroup.vue"
11
+ },
12
+ "FSIcon": {
13
+ "from": "@dative-gpi/foundation-shared-components/components/FSIcon.vue"
14
+ },
15
+ "FSRow": {
16
+ "from": "@dative-gpi/foundation-shared-components/components/FSRow.vue"
17
+ },
18
+ "FSTabs": {
19
+ "from": "@dative-gpi/foundation-shared-components/components/FSTabs.vue"
20
+ },
21
+ "FSWrapGroup": {
22
+ "from": "@dative-gpi/foundation-shared-components/components/FSWrapGroup.vue"
23
+ },
24
+ "FSCol": {
25
+ "from": "@dative-gpi/foundation-shared-components/components/FSCol.vue"
26
+ },
27
+ "FSRadio": {
28
+ "from": "@dative-gpi/foundation-shared-components/components/FSRadio.vue"
29
+ },
30
+ "FSButton": {
31
+ "from": "@dative-gpi/foundation-shared-components/components/FSButton.vue"
32
+ },
33
+ "FSTag": {
34
+ "from": "@dative-gpi/foundation-shared-components/components/FSTag.vue"
35
+ },
36
+ "FSTab": {
37
+ "from": "@dative-gpi/foundation-shared-components/components/FSTab.vue"
38
+ },
39
+ "FSFadeOut": {
40
+ "from": "@dative-gpi/foundation-shared-components/components/FSFadeOut.vue"
41
+ },
42
+ "FSBreadcrumbs": {
43
+ "from": "@dative-gpi/foundation-shared-components/components/FSBreadcrumbs.vue"
44
+ },
45
+ "FSTextField": {
46
+ "from": "@dative-gpi/foundation-shared-components/components/FSTextField.vue"
47
+ },
48
+ "FSRadioGroup": {
49
+ "from": "@dative-gpi/foundation-shared-components/components/FSRadioGroup.vue"
50
+ },
51
+ "FSCheckbox": {
52
+ "from": "@dative-gpi/foundation-shared-components/components/FSCheckbox.vue"
53
+ },
54
+ "FSNumberField": {
55
+ "from": "@dative-gpi/foundation-shared-components/components/FSNumberField.vue"
56
+ },
57
+ "FSPasswordField": {
58
+ "from": "@dative-gpi/foundation-shared-components/components/FSPasswordField.vue"
59
+ },
60
+ "FSSwitch": {
61
+ "from": "@dative-gpi/foundation-shared-components/components/FSSwitch.vue"
62
+ }
63
+ },
64
+ "directives": []
65
+ }
@@ -0,0 +1,42 @@
1
+ import os
2
+ import json
3
+
4
+ PROJECTS = {
5
+ "foundation-shared-components": "../foundation-shared-components",
6
+ "foundation-admin-components": "../../admin/foundation-admin-components",
7
+ "foundation-core-components": "../../core/foundation-core-components",
8
+ "foundation-extension-components": "../../extension/foundation-extension-components",
9
+ # Ajoutez d'autres projets ici si nécessaire
10
+ }
11
+
12
+ def find_vue_files(project_name, directory):
13
+ components_dict = {}
14
+ for root, dirs, files in os.walk(directory):
15
+ for file in files:
16
+ if file.endswith(".vue"):
17
+ component_path = os.path.relpath(os.path.join(root, file), start=directory)
18
+ full_relative_path = os.path.join("@dative-gpi", project_name, component_path)
19
+ file_name_without_extension = os.path.splitext(file)[0]
20
+ components_dict[file_name_without_extension] = {
21
+ "from": full_relative_path
22
+ }
23
+ return components_dict
24
+
25
+ def main():
26
+ # Crée le dossier 'mapping' s'il n'existe pas dans le répertoire courant du script
27
+ mapping_directory = "./plugin/mapping"
28
+ os.makedirs(mapping_directory, exist_ok=True)
29
+
30
+ for project_name, project_root in PROJECTS.items():
31
+ components = find_vue_files(project_name, project_root)
32
+ data = {
33
+ "components": components,
34
+ "directives": []
35
+ }
36
+ output_file = os.path.join(mapping_directory, f"{project_name}-imports-map.json")
37
+ with open(output_file, "w", encoding="utf-8") as f:
38
+ json.dump(data, f, ensure_ascii=False, indent=4)
39
+ print(f"Vue structure file for '{project_name}' created at {output_file}")
40
+
41
+ if __name__ == "__main__":
42
+ main()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dative-gpi/foundation-shared-loader",
3
- "version": "0.0.2",
3
+ "version": "0.0.5",
4
4
  "main": "dist/index.js",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -8,6 +8,9 @@
8
8
  "scripts": {
9
9
  "build": "npx tsc --resolveJsonModule"
10
10
  },
11
+ "compilerOptions": {
12
+ "resolveJsonModule": true
13
+ },
11
14
  "types": "dist/index.d.ts",
12
15
  "keywords": [
13
16
  "vite-plugin"
@@ -15,12 +18,10 @@
15
18
  "description": "",
16
19
  "devDependencies": {
17
20
  "@babel/types": "^7.23.0",
18
- "@dative-gpi/foundation-admin-components": "0.0.2",
19
- "@dative-gpi/foundation-core-components": "0.0.2",
20
- "@dative-gpi/foundation-shared-components": "0.0.2",
21
21
  "@types/node": "^20.8.9",
22
22
  "typescript": "^5.2.2",
23
- "vite": "^4.5.0"
23
+ "vite": "^4.5.0",
24
+ "vue": "^3.2.0"
24
25
  },
25
- "gitHead": "44e9629c836e0cd06289b208b53120f07775ea5e"
26
+ "gitHead": "609abe1b97549b28ff83dffe858030604df27a2e"
26
27
  }
@@ -1,7 +1,7 @@
1
1
  import { getImports } from './getImports'
2
2
 
3
- export function generateImports (source: string) {
4
- const { imports, components, directives } = getImports(source)
3
+ export function generateImports (source: string, skipShared: boolean, skipCore: boolean, skipAdmin: boolean, skipExtension: boolean) {
4
+ const { imports, components, directives } = getImports(source, skipShared, skipCore, skipAdmin, skipExtension)
5
5
 
6
6
  let code = ''
7
7
 
@@ -1,9 +1,10 @@
1
1
  import { parseTemplate, type TemplateMatch } from './parseTemplate'
2
- import * as sharedImportMap from '@dative-gpi/foundation-shared-components/importMap.json'
3
- import * as coreImportMap from '@dative-gpi/foundation-core-components/importMap.json'
4
- import * as adminImportMap from '@dative-gpi/foundation-admin-components/importMap.json'
2
+ import * as sharedImportMap from './mapping/foundation-shared-components-imports-map.json'
3
+ import * as coreImportMap from './mapping/foundation-core-components-imports-map.json'
4
+ import * as adminImportMap from './mapping/foundation-admin-components-imports-map.json'
5
+ import * as extensionImportMap from './mapping/foundation-extension-components-imports-map.json'
5
6
 
6
- export function getImports (source: string) {
7
+ export function getImports (source: string, skipShared: boolean, skipCore: boolean, skipAdmin: boolean, skipExtension: boolean) {
7
8
  const { components, directives } = parseTemplate(source)
8
9
  const resolvedComponents: TemplateMatch[] = []
9
10
  const resolvedDirectives: TemplateMatch[] = []
@@ -11,18 +12,22 @@ export function getImports (source: string) {
11
12
 
12
13
  if (components.size || directives.size) {
13
14
  components.forEach(component => {
14
- if (component.name in sharedImportMap.components) {
15
+ if (!skipShared && component.name in sharedImportMap.components) {
15
16
  resolvedComponents.push(component)
16
17
  addImport(imports, component.name, component.symbol, (sharedImportMap.components as any)[component.name].from)
17
18
  }
18
- else if (component.name in coreImportMap.components) {
19
+ else if (!skipCore && component.name in coreImportMap.components) {
19
20
  resolvedComponents.push(component)
20
21
  addImport(imports, component.name, component.symbol, (coreImportMap.components as any)[component.name].from)
21
22
  }
22
- else if (component.name in adminImportMap.components) {
23
+ else if (!skipAdmin && component.name in adminImportMap.components) {
23
24
  resolvedComponents.push(component)
24
25
  addImport(imports, component.name, component.symbol, (adminImportMap.components as any)[component.name].from)
25
26
  }
27
+ else if (!skipExtension && component.name in extensionImportMap.components) {
28
+ resolvedComponents.push(component)
29
+ addImport(imports, component.name, component.symbol, (extensionImportMap.components as any)[component.name].from)
30
+ }
26
31
  })
27
32
  // directives.forEach(directive => {
28
33
  // if (importMap.directives.includes(directive.name)) {
@@ -12,7 +12,7 @@ function parseId(id: string) {
12
12
  }
13
13
  }
14
14
 
15
- export function importPlugin(): Plugin {
15
+ export function importPlugin(skipShared: boolean, skipCore: boolean, skipAdmin: boolean, skipExtension: boolean): Plugin {
16
16
  return {
17
17
  name: 'foundation:import',
18
18
  configResolved(config) {
@@ -27,7 +27,7 @@ export function importPlugin(): Plugin {
27
27
  ((!query || !('vue' in query)) && extname(path) === '.vue' && !/^import { render as _sfc_render } from ".*"$/m.test(code)) ||
28
28
  (query && 'vue' in query && (query.type === 'template' || (query.type === 'script' && query.setup === 'true')))
29
29
  ) {
30
- const { code: imports, source } = generateImports(code)
30
+ const { code: imports, source } = generateImports(code, skipShared, skipCore, skipAdmin, skipExtension)
31
31
  return {
32
32
  code: source + imports,
33
33
  map: null,
package/plugin/index.ts CHANGED
@@ -2,9 +2,14 @@ import { Plugin } from 'vite'
2
2
 
3
3
  import { importPlugin } from './importPlugin'
4
4
 
5
- function FoundationSharedAutoImport ( ): Plugin[] {
5
+ function FoundationSharedAutoImport ({
6
+ skipShared = false,
7
+ skipCore = false,
8
+ skipAdmin = false,
9
+ skipExtension = false
10
+ } = {}): Plugin[] {
6
11
  const plugins: Plugin[] = []
7
- plugins.push(importPlugin())
12
+ plugins.push(importPlugin(skipShared, skipCore, skipAdmin, skipExtension))
8
13
 
9
14
  return plugins
10
15
  }
@@ -0,0 +1,4 @@
1
+ {
2
+ "components": {},
3
+ "directives": []
4
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "components": {
3
+ "FSCoreButton": {
4
+ "from": "@dative-gpi/foundation-core-components/components/FSCoreButton.vue"
5
+ }
6
+ },
7
+ "directives": []
8
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "components": {},
3
+ "directives": []
4
+ }
@@ -0,0 +1,65 @@
1
+ {
2
+ "components": {
3
+ "FSWindow": {
4
+ "from": "@dative-gpi/foundation-shared-components/components/FSWindow.vue"
5
+ },
6
+ "FSSpan": {
7
+ "from": "@dative-gpi/foundation-shared-components/components/FSSpan.vue"
8
+ },
9
+ "FSSlideGroup": {
10
+ "from": "@dative-gpi/foundation-shared-components/components/FSSlideGroup.vue"
11
+ },
12
+ "FSIcon": {
13
+ "from": "@dative-gpi/foundation-shared-components/components/FSIcon.vue"
14
+ },
15
+ "FSRow": {
16
+ "from": "@dative-gpi/foundation-shared-components/components/FSRow.vue"
17
+ },
18
+ "FSTabs": {
19
+ "from": "@dative-gpi/foundation-shared-components/components/FSTabs.vue"
20
+ },
21
+ "FSWrapGroup": {
22
+ "from": "@dative-gpi/foundation-shared-components/components/FSWrapGroup.vue"
23
+ },
24
+ "FSCol": {
25
+ "from": "@dative-gpi/foundation-shared-components/components/FSCol.vue"
26
+ },
27
+ "FSRadio": {
28
+ "from": "@dative-gpi/foundation-shared-components/components/FSRadio.vue"
29
+ },
30
+ "FSButton": {
31
+ "from": "@dative-gpi/foundation-shared-components/components/FSButton.vue"
32
+ },
33
+ "FSTag": {
34
+ "from": "@dative-gpi/foundation-shared-components/components/FSTag.vue"
35
+ },
36
+ "FSTab": {
37
+ "from": "@dative-gpi/foundation-shared-components/components/FSTab.vue"
38
+ },
39
+ "FSFadeOut": {
40
+ "from": "@dative-gpi/foundation-shared-components/components/FSFadeOut.vue"
41
+ },
42
+ "FSBreadcrumbs": {
43
+ "from": "@dative-gpi/foundation-shared-components/components/FSBreadcrumbs.vue"
44
+ },
45
+ "FSTextField": {
46
+ "from": "@dative-gpi/foundation-shared-components/components/FSTextField.vue"
47
+ },
48
+ "FSRadioGroup": {
49
+ "from": "@dative-gpi/foundation-shared-components/components/FSRadioGroup.vue"
50
+ },
51
+ "FSCheckbox": {
52
+ "from": "@dative-gpi/foundation-shared-components/components/FSCheckbox.vue"
53
+ },
54
+ "FSNumberField": {
55
+ "from": "@dative-gpi/foundation-shared-components/components/FSNumberField.vue"
56
+ },
57
+ "FSPasswordField": {
58
+ "from": "@dative-gpi/foundation-shared-components/components/FSPasswordField.vue"
59
+ },
60
+ "FSSwitch": {
61
+ "from": "@dative-gpi/foundation-shared-components/components/FSSwitch.vue"
62
+ }
63
+ },
64
+ "directives": []
65
+ }
package/tsconfig.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "CommonJS",
5
- "outDir": "./dist",
6
- "rootDir": "./plugin",
7
- "strict": false,
8
- "declaration": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true
11
- },
12
- "include": ["plugin/**/*.ts", "plugin/importMap.json"]
13
- }
14
-
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "CommonJS",
5
+ "outDir": "./dist",
6
+ "rootDir": "./plugin",
7
+ "strict": false,
8
+ "declaration": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true
11
+ },
12
+ "include": [
13
+ "plugin/**/*.ts"
14
+ ]
15
+ }