@citolab/tspci-qbci 2.4.2 → 2.4.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citolab/tspci-qbci",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "description": "create a .ci file that can be imported into Questify",
5
5
  "author": "patrick <patrick.deklein@cito.nl>, Marcel Hoekstra <marcel.hoekstra@cito.nl>",
6
6
  "repository": "",
@@ -10,7 +10,7 @@
10
10
  "archiver": "^5.3.0"
11
11
  },
12
12
  "scripts": {},
13
- "gitHead": "c8d87c1b9f0270864b9df9dc3afcf1937e6583d4",
13
+ "gitHead": "332d6bc561050b4bd827c8abf9d9c0376b6870d7",
14
14
  "publishConfig": {
15
15
  "access": "public"
16
16
  }
package/readme.md CHANGED
@@ -10,7 +10,7 @@ tspci --target qbci
10
10
  ## config options
11
11
 
12
12
  In the package.json of the pci:
13
- - typeIdentifier (required)
13
+ - config: { tspci: { typeIdentifier: 'yourpciname' }} (required)
14
14
  - label (if empty, package name will be used)
15
- - width
16
- - height
15
+ - config: { tspci: { width: '500' }} (optional, default: 500)
16
+ - config: { tspci: { height: '500' }} (optional, default: 500)
@@ -38,8 +38,11 @@ export const bundle = () => {
38
38
  const rawMetadata = fs.readFileSync(questifyMetadata);
39
39
  const questifyMetadataData = JSON.parse(rawMetadata);
40
40
 
41
- const propertiesToCopy = ["width", "height"];
42
-
41
+ const propertiesToReplace = {
42
+ typeIdentifier: "emptytypeIdentifier",
43
+ width: "500",
44
+ height: "500",
45
+ };
43
46
  copyDirectoryRecursiveSync(path.join(PACKAGER_PATH, "questify-default"), outputDirectoryTemp, false);
44
47
 
45
48
  const name = packageData.label
@@ -47,18 +50,36 @@ export const bundle = () => {
47
50
  : packageData.name
48
51
  ? packageData.name.split("/")[packageData.name.split("/").length - 1]
49
52
  : "ci";
50
- const typeIdentifier = packageData.typeIdentifier;
51
- if (!typeIdentifier) {
52
- console.error("missing type identifier in package.json");
53
- process.exit();
54
- }
55
- questifyMetadataData.typeIdentifier = typeIdentifier;
56
- questifyMetadataData.title = name;
57
- for (const propertyName in propertiesToCopy) {
58
- if (packageData[propertyName]) {
59
- questifyMetadataData[propertyName] = packageData[propertyName];
53
+
54
+ for (const propertyName in propertiesToReplace) {
55
+ if (!packageData.config?.tspci[propertyName]) {
56
+ console.error(
57
+ "'typeIdentifier' should be added as an option in package.json and should match the typeIdentifier of the PCI code file."
58
+ );
59
+ return;
60
+ }
61
+ if (propertyName === "typeIdentifier") {
62
+ if (!packageData.config?.tspci[propertyName]) {
63
+ console.error(
64
+ "'typeIdentifier' should be added as an option in package.json and should match the typeIdentifier of the PCI code file."
65
+ );
66
+ return;
67
+ } else {
68
+ if (!packageData.config?.tspci[propertyName])
69
+ console.info(
70
+ `${propertyName} not specified in ${packageData.name} in package.json using { config: tspci: {${propertiesToReplace[propertyName]}}`
71
+ );
72
+ }
73
+ }
74
+ if ( packageData.config.tspci[propertyName]) {
75
+ propertiesToReplace[propertyName] = packageData.config.tspci[propertyName];
60
76
  }
61
77
  }
78
+
79
+ for(const propertyName in propertiesToReplace) {
80
+ questifyMetadataData[propertyName] = propertiesToReplace[propertyName];
81
+ }
82
+
62
83
  const metadataString = JSON.stringify(questifyMetadataData);
63
84
  fs.writeFileSync(path.join(outputDirectoryTemp, "metadata.json"), metadataString, "utf8");
64
85
 
@@ -66,10 +87,11 @@ export const bundle = () => {
66
87
  const pciFile = config.main || "/dist/index.js";
67
88
 
68
89
  // pk: add .min. to the name else QB is gonna minify it and it BREAKS
90
+ const scriptPath = path.join(outputDirectoryTemp, "/ref/script");
69
91
  if (!fs.existsSync(scriptPath)) {
70
92
  fs.mkdirSync(scriptPath);
71
93
  }
72
- fs.copyFileSync(path.join(PACKAGE_ROOT_PATH, pciFile), path.join(outputDirectoryTemp, "/ref/script/index.min.js"));
94
+ fs.copyFileSync(path.join(PACKAGE_ROOT_PATH, pciFile), path.join(scriptPath, "/index.min.js"));
73
95
 
74
96
  // zip the folder
75
97
  const zipName = `questify-ci-${name}_${packageData.version}.ci`;