r2-explorer 0.2.0
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/.eslintrc.yml +31 -0
- package/bin/r2-explorer.js +45 -0
- package/dist/index.js +210 -0
- package/package.json +31 -0
- package/rollup.config.js +40 -0
- package/spa/favicon.png +0 -0
- package/spa/index.html +1 -0
- package/spa/js/app.js +127 -0
- package/spa/js/app.js.map +1 -0
- package/src/api/core.js +12 -0
- package/src/api/createFolder.js +13 -0
- package/src/api/deleteObject.js +15 -0
- package/src/api/downloadFile.js +23 -0
- package/src/api/listContents.js +27 -0
- package/src/api/listDisks.js +15 -0
- package/src/api/renameObject.js +24 -0
- package/src/api/uploadFiles.js +23 -0
- package/src/index.js +60 -0
- package/wrangler.toml +15 -0
package/.eslintrc.yml
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
env:
|
|
2
|
+
browser: true
|
|
3
|
+
es6: true
|
|
4
|
+
|
|
5
|
+
extends: 'eslint:recommended'
|
|
6
|
+
|
|
7
|
+
parserOptions:
|
|
8
|
+
ecmaVersion: 9
|
|
9
|
+
sourceType: module
|
|
10
|
+
|
|
11
|
+
rules:
|
|
12
|
+
indent:
|
|
13
|
+
- error
|
|
14
|
+
- 2
|
|
15
|
+
linebreak-style:
|
|
16
|
+
- error
|
|
17
|
+
- unix
|
|
18
|
+
quotes:
|
|
19
|
+
- error
|
|
20
|
+
- single
|
|
21
|
+
semi:
|
|
22
|
+
- off
|
|
23
|
+
no-unused-vars:
|
|
24
|
+
- warn
|
|
25
|
+
- args: none
|
|
26
|
+
no-empty:
|
|
27
|
+
- warn
|
|
28
|
+
no-trailing-spaces:
|
|
29
|
+
- error
|
|
30
|
+
|
|
31
|
+
root: true
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
var fs = require('fs');
|
|
3
|
+
|
|
4
|
+
const projectName = process.argv.slice(1) || 'r2-explorer';
|
|
5
|
+
|
|
6
|
+
const dir = `./${projectName}`
|
|
7
|
+
if (!fs.existsSync(dir)) {
|
|
8
|
+
fs.mkdirSync(dir);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
fs.writeFileSync(`${dir}/wrangler.toml`,
|
|
12
|
+
`name = "${projectName}"
|
|
13
|
+
compatibility_date = "2022-08-09"
|
|
14
|
+
main = "src/index.js"
|
|
15
|
+
|
|
16
|
+
[[r2_buckets]]
|
|
17
|
+
binding = 'my-bucket-name'
|
|
18
|
+
bucket_name = 'my-bucket-name'
|
|
19
|
+
preview_bucket_name = 'my-bucket-name'
|
|
20
|
+
`);
|
|
21
|
+
|
|
22
|
+
const srcDir = `${dir}/src`
|
|
23
|
+
if (!fs.existsSync(srcDir)) {
|
|
24
|
+
fs.mkdirSync(srcDir);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
fs.writeFileSync(`${srcDir}/index.js`,
|
|
28
|
+
`import { R2Explorer } from 'r2-explorer';
|
|
29
|
+
|
|
30
|
+
const explorer = R2Explorer()
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
async fetch(request, env, context) {
|
|
34
|
+
return explorer.handle(request, env, context)
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
`);
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
console.log(`Project ${projectName} successfully created!`);
|
|
41
|
+
console.log('----------------------------');
|
|
42
|
+
console.log(`Update the ${projectName}/wrangler.toml file with your R2 Buckets`);
|
|
43
|
+
console.log(`Run 'cd ${projectName} && wrangler publish' to deploy your R2-Explorer!`);
|
|
44
|
+
|
|
45
|
+
process.exit(0); //no errors occurred
|