Skip to content

Commit b144758

Browse files
authored
Merge pull request #625 from swrlab/dev/622-remove-s3
refact!: remove aws-sdk integration (s3)
2 parents f4d9d85 + 585aa37 commit b144758

30 files changed

+1590
-1967
lines changed

.eslintrc.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/linter.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Linter
22

33
on:
4-
push:
5-
branches-ignore:
6-
- 'dependabot/**'
74
workflow_call:
85
inputs:
96
install-all:
@@ -35,7 +32,7 @@ on:
3532
description: 'Path to the ESLint configuration file'
3633
required: false
3734
type: string
38-
default: '/.eslintrc.json'
35+
default: '/eslint.config.mjs'
3936

4037
env:
4138
CSS_FILE_NAME: /.stylelintrc.json

.stylelintrc.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
{
22
"defaultSeverity": "warning",
3-
"extends": ["stylelint-config-standard-scss", "stylelint-config-recommended-vue/scss"],
4-
"ignoreFiles": ["**/static-ui/dist/*", "**/ati-smarttag.js", "**/skycons.js"],
3+
"extends": [
4+
"stylelint-config-standard-scss",
5+
"stylelint-config-recommended-vue/scss"
6+
],
7+
"ignoreFiles": [
8+
"**/static-ui/dist/*",
9+
"**/ati-smarttag.js",
10+
"**/skycons.js"
11+
],
512
"rules": {
613
"declaration-empty-line-before": null,
714
"indentation": "tab",

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ by [**SWR Audio Lab**](https://lab.swr.de/)
44

55
## Changelog
66

7+
- 2024-07-10 - v2.0.0
8+
9+
- refact!: remove aws-sdk integration (s3)
10+
- refact!: remove `ard:publishers` and `ard:pub-sort` scripts
11+
- chore!: switch super-linter ESLint config default to `/eslint.config.mjs`
12+
713
- 2024-05-13 - v1.3.0
814

915
- chore: update dependencies

eslint.config.mjs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { audiolab } from '@swrlab/style-guide/eslint/index'
2+
3+
export default audiolab(
4+
[
5+
{
6+
ignores: [],
7+
},
8+
{
9+
rules: {
10+
// previous config (does not trigger errors)
11+
// 'import/no-extraneous-dependencies': 0,
12+
// radix: 0,
13+
// 'no-param-reassign': [2, { props: false }],
14+
// 'no-restricted-syntax': 0,
15+
// 'no-underscore-dangle': 0,
16+
// 'no-return-assign': ['error', 'except-parens'],
17+
// 'one-var': 0,
18+
19+
// should be fixed / easy to fix
20+
'prefer-promise-reject-errors': 'off',
21+
'n/prefer-global/process': 'off',
22+
'n/prefer-global/buffer': 'off',
23+
'n/no-process-exit': 'off',
24+
'n/no-unpublished-import': 'off',
25+
'n/no-unpublished-require': 'off',
26+
'eslint-comments/require-description': 'off',
27+
'vue/multi-word-component-names': 'off',
28+
// could be fixed when converting to ESM
29+
'import/order': 'off',
30+
// a bit more complex to fix (but nice idea in general)
31+
'import/no-default-export': 'off',
32+
'no-console': 'off',
33+
'func-names': 'off',
34+
'jsonc/sort-keys': 'off',
35+
36+
// harder to fix
37+
},
38+
},
39+
],
40+
{
41+
prettier: true,
42+
comments: true,
43+
}
44+
)

package.json

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,41 @@
11
{
22
"name": "@swrlab/utils",
3-
"version": "1.3.0",
3+
"version": "2.0.0-beta",
44
"description": "Wrapping common SWR Audio Lab utils",
5-
"main": "./index.js",
6-
"engines": {
7-
"node": ">=20"
8-
},
95
"repository": {
106
"type": "git",
117
"url": "https://github.com/swrlab/node-utils"
128
},
9+
"author": "SWR Audio Lab <[email protected]>",
10+
"license": "MIT",
11+
"main": "./index.js",
1312
"scripts": {
1413
"ard:coreId": "node ./scripts/ard/coreId.js",
1514
"ard:categories": "node -r dotenv/config scripts/ard/categories.js",
16-
"ard:publishers": "node -r dotenv/config scripts/ard/publishers.js",
17-
"ard:pub-sort": "node -r dotenv/config scripts/ard/sortPubByExtId.js",
1815
"lint": "eslint .",
1916
"test": "mocha tests/**.js -r dotenv/config",
2017
"outdated": "yarn upgrade-interactive",
2118
"reinstall": "rm -rf node_modules && rm yarn.lock && touch yarn.lock && yarn"
2219
},
23-
"author": "SWR Audio Lab <[email protected]>",
24-
"license": "MIT",
2520
"dependencies": {
26-
"@google-cloud/storage": "^7.11.0",
21+
"@google-cloud/storage": "^7.11.3",
2722
"abort-controller": "^3.0.0",
28-
"aws-sdk": "2.1618.0",
2923
"luxon": "3.4.4",
3024
"node-crc": "swrlab/node-crc#v2.1.0",
31-
"undici": "6.16.1"
25+
"undici": "6.19.2"
3226
},
3327
"devDependencies": {
34-
"@swrlab/eslint-plugin-swr": "^0.3.0",
35-
"@swrlab/swr-prettier-config": "^0.3.0",
28+
"@swrlab/style-guide": "https://github.com/swrlab/style-guide.git",
3629
"chai": "4.4.1",
3730
"dotenv": "^16.4.5",
38-
"eslint": "^8.57.0",
39-
"eslint-plugin-json": "^3.1.0",
40-
"mocha": "^10.4.0",
41-
"prettier": "^3.2.5"
31+
"eslint": "^9.6.0",
32+
"eslint-plugin-json": "^4.0.0",
33+
"mocha": "^10.6.0",
34+
"prettier": "^3.3.2"
35+
},
36+
"engines": {
37+
"node": ">=20"
4238
},
43-
"prettier": "@swrlab/swr-prettier-config",
44-
"packageManager": "[email protected]"
39+
"packageManager": "[email protected]",
40+
"prettier": "@swrlab/style-guide/prettier"
4541
}

packages/storage-wrapper/createUrl.js

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable func-names */
21
/*
32
43
node-storage-wrapper
@@ -7,48 +6,36 @@
76
87
*/
98

10-
module.exports = async function (uri, ttl, logPrefix) {
11-
const thisLogPrefix = logPrefix ? [logPrefix, '>'] : []
12-
13-
if (uri.substr(0, 5).toLowerCase() === 's3://') {
14-
// log progress
15-
this.sdk.log(this, 'log', thisLogPrefix.concat(['storage.createUrl.aws >', uri]))
16-
17-
return Promise.reject(new Error('not implemented'))
18-
}
19-
9+
module.exports = async function (uri, ttl) {
2010
if (uri.substr(0, 5).toLowerCase() === 'gs://') {
2111
// google cloud storage
2212
const structure = uri.substr(5).split('/')
2313
const bucket = structure.shift()
2414
const path = structure.join('/')
2515

26-
// log progress
27-
this.sdk.log(this, 'log', thisLogPrefix.concat(['storage.createUrl.gcp >', uri]))
28-
2916
// set config
3017
const config = {
3118
action: 'read',
3219
expires: Date.now() + ttl,
3320
}
3421

3522
// create link
36-
const [url] = await this.sdk.gs.bucket(bucket).file(path).getSignedUrl(config)
23+
const [url] = await this.sdk.gs
24+
.bucket(bucket)
25+
.file(path)
26+
.getSignedUrl(config)
3727

3828
// return link
3929
return Promise.resolve(url)
4030
}
4131

42-
if (uri.substr(0, 7).toLowerCase() === 'http://' || uri.substr(0, 8).toLowerCase() === 'https://') {
43-
// log progress
44-
this.sdk.log(this, 'log', thisLogPrefix.concat(['storage.createUrl.https >', uri]))
45-
32+
if (
33+
uri.substr(0, 7).toLowerCase() === 'http://' ||
34+
uri.substr(0, 8).toLowerCase() === 'https://'
35+
) {
4636
// return link
4737
return Promise.resolve(uri)
4838
}
4939

50-
// log progress
51-
this.sdk.log(this, 'log', thisLogPrefix.concat(['storage.createUrl.local >', uri]))
52-
5340
return Promise.reject(new Error('not implemented'))
5441
}

packages/storage-wrapper/delete.js

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable func-names */
21
/*
32
43
node-storage-wrapper
@@ -13,39 +12,12 @@ const deleteLocalFile = (that, filePath) =>
1312
})
1413
})
1514

16-
module.exports = async function (uri, logPrefix) {
17-
const thisLogPrefix = logPrefix ? [logPrefix, '>'] : []
18-
let structure, bucket, path
19-
20-
if (uri.substr(0, 5).toLowerCase() === 's3://') {
21-
// aws s3 file
22-
structure = uri.substr(5).split('/')
23-
bucket = structure.shift()
24-
path = structure.join('/')
25-
26-
// log progress
27-
this.sdk.log(this, 'log', thisLogPrefix.concat(['storage.delete.s3 >', uri]))
28-
29-
// delete from aws
30-
await this.sdk.s3
31-
.deleteObject({
32-
Bucket: bucket,
33-
Key: path,
34-
})
35-
.promise()
36-
37-
// return ok
38-
return Promise.resolve()
39-
}
40-
15+
module.exports = async function (uri) {
4116
if (uri.substr(0, 5).toLowerCase() === 'gs://') {
4217
// google cloud storage
43-
structure = uri.substr(5).split('/')
44-
bucket = structure.shift()
45-
path = structure.join('/')
46-
47-
// log progress
48-
this.sdk.log(this, 'log', thisLogPrefix.concat(['storage.delete.gs >', uri]))
18+
const structure = uri.substr(5).split('/')
19+
const bucket = structure.shift()
20+
const path = structure.join('/')
4921

5022
// delete from gcp
5123
await this.sdk.gs.bucket(bucket).file(path).delete(path)
@@ -54,17 +26,14 @@ module.exports = async function (uri, logPrefix) {
5426
return Promise.resolve()
5527
}
5628

57-
if (uri.substr(0, 7).toLowerCase() === 'http://' || uri.substr(0, 8).toLowerCase() === 'https://') {
58-
// log progress
59-
this.sdk.log(this, 'log', thisLogPrefix.concat(['storage.delete.https (not possible) >', uri]))
60-
29+
if (
30+
uri.substr(0, 7).toLowerCase() === 'http://' ||
31+
uri.substr(0, 8).toLowerCase() === 'https://'
32+
) {
6133
// return ok
6234
return Promise.resolve()
6335
}
6436

65-
// log progress
66-
this.sdk.log(this, 'log', thisLogPrefix.concat(['storage.delete.local >', uri]))
67-
6837
// delete file
6938
await deleteLocalFile(this, uri)
7039

packages/storage-wrapper/index.js

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
/* eslint-disable global-require */
21
/*
32
43
node-storage-wrapper
54
65
*/
76

87
// load node utils
9-
const AWS = require('aws-sdk')
10-
const fs = require('fs')
8+
const fs = require('node:fs')
119
const { Storage } = require('@google-cloud/storage')
1210

1311
// create wrapper
1412
function StorageWrapper(config) {
1513
// check config
16-
if (!config || !config.gs) return Promise.reject(new Error('storage config invalid'))
14+
if (!config || !config.gs)
15+
return Promise.reject(new Error('storage config invalid'))
1716

1817
// enable SDKs
1918
this.sdk = {}
@@ -24,27 +23,6 @@ function StorageWrapper(config) {
2423
// load google cloud storage sdk
2524
this.sdk.gs = new Storage(config.gs)
2625

27-
// load aws sdk
28-
if (config.s3) {
29-
this.sdk.s3 = new AWS.S3(config.s3)
30-
}
31-
32-
// configure logging
33-
this.config = {
34-
logging: config.logging,
35-
}
36-
37-
// set logging
38-
this.sdk.log = (that, level, message) => {
39-
let thisMessage
40-
if (message instanceof Array) thisMessage = message.join(' ')
41-
else thisMessage = message
42-
43-
if (level === 'log' && that.config.logging) console.log(thisMessage)
44-
else if (level === 'warn' && that.config.logging) console.warn(thisMessage)
45-
else if (level === 'error' && that.config.logging) console.error(thisMessage)
46-
}
47-
4826
// import functions
4927
this.createUri = require('./createUri')
5028
this.createUrl = require('./createUrl')
@@ -53,16 +31,6 @@ function StorageWrapper(config) {
5331
this.load = require('./load')
5432
this.move = require('./move')
5533
this.save = require('./save')
56-
57-
// log progress
58-
this.sdk.log(this, 'log', [
59-
'storage.index',
60-
'loaded config',
61-
JSON.stringify({
62-
gs: config.gs ? config.gs.projectId : null,
63-
s3: config.s3 ? { accessKeyId: config.s3.accessKeyId, region: config.s3.region } : null,
64-
}),
65-
])
6634
}
6735

6836
// export

0 commit comments

Comments
 (0)