r2-explorer 0.2.5 → 0.2.7

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/bin/r2-explorer.js +70 -0
  2. package/package.json +1 -1
@@ -0,0 +1,70 @@
1
+ #! /usr/bin/env node
2
+ var fs = require('fs')
3
+
4
+ const args = process.argv.slice(2)
5
+ const projectName = args[0] || 'r2-explorer'
6
+
7
+ const dir = `./${projectName}`
8
+ if (!fs.existsSync(dir)) {
9
+ fs.mkdirSync(dir)
10
+ }
11
+
12
+ fs.writeFileSync(
13
+ `${dir}/wrangler.toml`,
14
+ `name = "${projectName}"
15
+ compatibility_date = "2022-08-09"
16
+ main = "src/index.js"
17
+
18
+ [[r2_buckets]]
19
+ binding = 'my-bucket-name'
20
+ bucket_name = 'my-bucket-name'
21
+ preview_bucket_name = 'my-bucket-name'
22
+ `
23
+ )
24
+ fs.writeFileSync(
25
+ `${dir}/package.json`,
26
+ `{
27
+ "name": "${projectName}",
28
+ "version": "0.0.1",
29
+ "private": true,
30
+ "devDependencies": {
31
+ "wrangler": "^2.4.2"
32
+ },
33
+ "scripts": {
34
+ "publish": "wrangler publish"
35
+ },
36
+ "dependencies": {
37
+ "r2-explorer": "^0.2.7"
38
+ }
39
+ }
40
+
41
+ `
42
+ )
43
+
44
+ const srcDir = `${dir}/src`
45
+ if (!fs.existsSync(srcDir)) {
46
+ fs.mkdirSync(srcDir)
47
+ }
48
+
49
+ fs.writeFileSync(
50
+ `${srcDir}/index.js`,
51
+ `import { R2Explorer } from 'r2-explorer';
52
+
53
+ const explorer = R2Explorer({ readonly: true })
54
+
55
+ export default {
56
+ async fetch(request, env, context) {
57
+ return explorer(request, env, context)
58
+ }
59
+ };
60
+ `
61
+ )
62
+
63
+ console.log(`Project ${projectName} successfully created!`)
64
+ console.log('----------------------------')
65
+ console.log('Next steps:')
66
+ console.log(` 1. Run 'cd ${projectName} && npm install'`)
67
+ console.log(" 2. Update the 'wrangler.toml' file with your R2 Buckets")
68
+ console.log(" 3. Run 'wrangler publish' to deploy your own R2-Explorer!")
69
+
70
+ process.exit(0) //no errors occurred
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "r2-explorer",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "A Google Drive Interface for your Cloudflare R2 Buckets",
5
5
  "main": "dist/umd/index.js",
6
6
  "scripts": {