@arela/uploader 0.0.6 → 0.0.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.
- package/package.json +1 -1
- package/src/index.js +14 -2
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -5,9 +5,13 @@ import { config } from 'dotenv';
|
|
|
5
5
|
import fs from 'fs';
|
|
6
6
|
import { globby } from 'globby';
|
|
7
7
|
import mime from 'mime-types';
|
|
8
|
+
import { createRequire } from 'module';
|
|
8
9
|
import ora from 'ora';
|
|
9
10
|
import path from 'path';
|
|
10
11
|
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
const { version } = require('../package.json');
|
|
14
|
+
|
|
11
15
|
config();
|
|
12
16
|
|
|
13
17
|
const program = new Command();
|
|
@@ -109,8 +113,12 @@ const fileExistsInBucket = async (pathInBucket) => {
|
|
|
109
113
|
|
|
110
114
|
const logFilePath = path.resolve(process.cwd(), 'upload.log');
|
|
111
115
|
const writeLog = (message) => {
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
try {
|
|
117
|
+
const timestamp = new Date().toISOString();
|
|
118
|
+
fs.appendFileSync(logFilePath, `[${timestamp}] ${message}\n`);
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error(`❌ Error writing to log file: ${err.message}`);
|
|
121
|
+
}
|
|
114
122
|
};
|
|
115
123
|
|
|
116
124
|
const getProcessedPaths = () => {
|
|
@@ -133,6 +141,7 @@ const getProcessedPaths = () => {
|
|
|
133
141
|
program
|
|
134
142
|
.name('supabase-uploader')
|
|
135
143
|
.description('CLI to upload folders from a base path to Supabase Storage')
|
|
144
|
+
.version(version)
|
|
136
145
|
.option('-p, --prefix <prefix>', 'Prefix path in bucket', '')
|
|
137
146
|
.action(async (options) => {
|
|
138
147
|
if (!basePath || !sources || sources.length === 0) {
|
|
@@ -210,6 +219,9 @@ program
|
|
|
210
219
|
.upload(uploadPath, content, {
|
|
211
220
|
upsert: true,
|
|
212
221
|
contentType,
|
|
222
|
+
metadata: {
|
|
223
|
+
originalName: path.basename(file),
|
|
224
|
+
},
|
|
213
225
|
});
|
|
214
226
|
|
|
215
227
|
if (error) {
|