build-firewall-plugin 0.0.3 → 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.
Files changed (2) hide show
  1. package/build/index.js +11 -11
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -85,45 +85,45 @@ class BuildFirewallPlugin {
85
85
  */
86
86
  if (!this.config.path) {
87
87
  try {
88
- const pathToFile = path_1.default.resolve(__dirname, this.config.name);
88
+ const pathToFile = path_1.default.resolve(compiler.context, this.config.name);
89
89
  fs_1.default.writeFileSync(pathToFile, JSON.stringify(template));
90
90
  this.shouldRunAgain = true;
91
91
  this.config.path = pathToFile;
92
- console.log(`Created a template of ${this.config.name} file successfully`);
93
- console.log(`Check and edit a ${this.config.name} file if it is not passing for your project`);
92
+ console.log(`[Build Firewall Plugin] Created a template of ${this.config.name} file successfully`);
93
+ console.log(`[Build Firewall Plugin] Check and edit a ${this.config.name} file if it is not passing for your project`);
94
94
  }
95
95
  catch (e) {
96
- console.error(`Could not create a rules file: \n ${e}`);
96
+ console.error(`[Build Firewall Plugin] Could not create a rules file: \n ${e}`);
97
97
  return;
98
98
  }
99
99
  ;
100
100
  }
101
101
  else {
102
102
  try {
103
- const pathToFile = path_1.default.resolve(__dirname, this.config.name);
103
+ const pathToFile = path_1.default.resolve(compiler.context, this.config.name);
104
104
  const rawFile = fs_1.default.readFileSync(pathToFile).toString();
105
105
  const extention = path_1.default.extname(pathToFile);
106
106
  const isJSON = extention.endsWith('.json');
107
107
  if (!isJSON) {
108
- console.error(`Your ${this.config.name} file is not a JSON`);
108
+ console.error(`[Build Firewall Plugin] Your ${this.config.name} file is not a JSON`);
109
109
  return;
110
110
  }
111
111
  ;
112
112
  if (rawFile.length < 0) {
113
- console.error(`Your ${this.config.name} file is empty`);
113
+ console.error(`[Build Firewall Plugin] Your ${this.config.name} file is empty`);
114
114
  return;
115
115
  }
116
116
  ;
117
117
  const parsedFile = JSON.parse(rawFile);
118
118
  const isObject = typeof parsedFile === 'object';
119
119
  if (!isObject) {
120
- console.error(`Your ${this.config.name} file value is not an object`);
120
+ console.error(`[Build Firewall Plugin] Your ${this.config.name} file value is not an object`);
121
121
  return;
122
122
  }
123
123
  ;
124
124
  const hasValidSchema = isValidSchema(parsedFile);
125
125
  if (!hasValidSchema) {
126
- console.error(`Your ${this.config.name} file value is not valid schema, it has to be like this: \n
126
+ console.error(`[Build Firewall Plugin] Your ${this.config.name} file value is not valid schema, it has to be like this: \n
127
127
  {
128
128
  layers: {
129
129
  [name]: { allow: [], deny: [] },
@@ -139,7 +139,7 @@ class BuildFirewallPlugin {
139
139
  console.log(`Your ${this.config.name} file is valid!`);
140
140
  }
141
141
  catch (e) {
142
- console.error(`Error while validating your ${this.config.name} file \n ${e}`);
142
+ console.error(`[Build Firewall Plugin] Error while validating your ${this.config.name} file \n ${e}`);
143
143
  return;
144
144
  }
145
145
  ;
@@ -179,7 +179,7 @@ class BuildFirewallPlugin {
179
179
  const isDenided = rules.deny.includes(toLayer);
180
180
  const isAllowed = rules.allow.includes(toLayer);
181
181
  if (isDenided || !isAllowed) {
182
- console.log(`Dependency ${toModuleResource} is not allowed to import in ${fromResource}`);
182
+ console.log(`[Build Firewall Plugin] Dependency ${toModuleResource} is not allowed to import in ${fromResource}`);
183
183
  }
184
184
  }
185
185
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "build-firewall-plugin",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "type": "commonjs",
5
5
  "license": "MIT",
6
6
  "main": "build/index.js",