node-red-contrib-padavan 1.0.0 → 1.0.2

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/main.mjs +4 -3
  2. package/package.json +1 -1
package/main.mjs CHANGED
@@ -202,12 +202,12 @@ export class Padavan {
202
202
  if (to_id.length > 7)
203
203
  to_id = to_id.slice(0, 7);
204
204
  if (from_id != to_id)
205
- return this.github('contents/variables', undefined, undefined, {
205
+ return this.github('contents/build.conf', undefined, undefined, {
206
206
  accept: 'application/vnd.github.raw+json'
207
207
  }).then(res => res.text()).then(text => {
208
208
  let [ padavan_repo ] = text.match(new RegExp('^PADAVAN_REPO="(.*?)"$', 'm'))?.slice(1) || [];
209
209
  if (!padavan_repo)
210
- throw new Error('PADAVAN_REPO not found in variables');
210
+ throw new Error('PADAVAN_REPO not found in build.conf');
211
211
  const firstSlashIndex = padavan_repo.indexOf('/', padavan_repo.indexOf('//') + 2);
212
212
  const host = padavan_repo.substring(padavan_repo.indexOf('//') + 2, firstSlashIndex);
213
213
  if (host !== 'gitlab.com')
@@ -246,7 +246,8 @@ export class Padavan {
246
246
  if (!id)
247
247
  id = (await this.getArtifact())?.id;
248
248
  return this.github(`actions/artifacts/${id}/zip`).then(res => res.arrayBuffer()).then(jszip.loadAsync).then(zip => {
249
- const [ firmware, config ] = Object.values(zip.files);
249
+ const regexp = new RegExp('(bin|trx)$');
250
+ const firmware = Object.values(zip.files).find(file => regexp.test(file.name));
250
251
  return firmware.async('blob').then(blob => {
251
252
  const data = new FormData();
252
253
  data.append('file', blob, firmware.name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-padavan",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Router management with Padavan firmware",
5
5
  "main": "main.mjs",
6
6
  "node-red": {