dorky 2.3.3 → 2.3.5
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/README.md +1 -0
- package/bin/index.js +15 -20
- package/package.json +1 -1
- package/web-app/README.md +0 -70
- package/web-app/package-lock.json +0 -17868
- package/web-app/package.json +0 -43
- package/web-app/public/favicon.ico +0 -0
- package/web-app/public/index.html +0 -43
- package/web-app/public/logo192.png +0 -0
- package/web-app/public/logo512.png +0 -0
- package/web-app/public/manifest.json +0 -25
- package/web-app/public/robots.txt +0 -3
- package/web-app/src/App.css +0 -23
- package/web-app/src/App.js +0 -84
- package/web-app/src/App.test.js +0 -8
- package/web-app/src/PrivacyPolicy.js +0 -26
- package/web-app/src/TermsAndConditions.js +0 -41
- package/web-app/src/index.css +0 -3
- package/web-app/src/index.js +0 -26
- package/web-app/src/logo.svg +0 -1
- package/web-app/src/reportWebVitals.js +0 -13
- package/web-app/src/setupTests.js +0 -5
- package/web-app/tailwind.config.js +0 -10
package/README.md
CHANGED
|
@@ -91,6 +91,7 @@ Anyhow, we shall store it on a private storage, using **dorky**, that stores it
|
|
|
91
91
|
[*] Update .gitignore automatically, to ignore .dorky/credentials.json.
|
|
92
92
|
[*] Handle reauthentication loop for google-drive. (Bug fix release)
|
|
93
93
|
[ ] Fix error while adding a file that does not exist, it does give an error but still prints that an entry is added.
|
|
94
|
+
[ ] Update README. (Bug fix release)
|
|
94
95
|
[ ] Fix issue when the file is added again with the same contents, it still adds it, not checks it with the hash.
|
|
95
96
|
[ ] Handle invalid access token for google-drive.
|
|
96
97
|
[ ] Extension for VS Code to list and highlight them like git. (Major release)
|
package/bin/index.js
CHANGED
|
@@ -105,12 +105,10 @@ async function authorizeGoogleDriveClient(forceReauth = false) {
|
|
|
105
105
|
const content = await fs.readFileSync(TOKEN_PATH);
|
|
106
106
|
const savedCredentials = JSON.parse(content);
|
|
107
107
|
|
|
108
|
-
// Check if this is OAuth2 credentials (has access_token, refresh_token, etc.)
|
|
109
108
|
if (!savedCredentials.access_token && !savedCredentials.refresh_token) {
|
|
110
109
|
return null;
|
|
111
110
|
}
|
|
112
111
|
|
|
113
|
-
// Load the client secrets to create an OAuth2 client
|
|
114
112
|
const keys = JSON.parse(fs.readFileSync(CREDENTIALS_PATH));
|
|
115
113
|
const key = keys.installed || keys.web;
|
|
116
114
|
const oAuth2Client = new google.auth.OAuth2(
|
|
@@ -119,7 +117,6 @@ async function authorizeGoogleDriveClient(forceReauth = false) {
|
|
|
119
117
|
key.redirect_uris[0]
|
|
120
118
|
);
|
|
121
119
|
|
|
122
|
-
// Remove the 'storage' field and set credentials
|
|
123
120
|
const { storage, ...authCredentials } = savedCredentials;
|
|
124
121
|
oAuth2Client.setCredentials(authCredentials);
|
|
125
122
|
|
|
@@ -133,13 +130,10 @@ async function authorizeGoogleDriveClient(forceReauth = false) {
|
|
|
133
130
|
if (!credentials.expiry_date) {
|
|
134
131
|
return true;
|
|
135
132
|
}
|
|
136
|
-
// Both Date.now() and expiry_date are in milliseconds since Unix epoch (UTC)
|
|
137
|
-
// Check if token expires in less than 5 minutes (300000 ms)
|
|
138
133
|
const expiryBuffer = 300000;
|
|
139
134
|
const currentTimeUTC = Date.now();
|
|
140
135
|
const expiryTimeUTC = credentials.expiry_date;
|
|
141
136
|
|
|
142
|
-
// Token is expired if current time is past (expiry time - buffer)
|
|
143
137
|
return currentTimeUTC >= (expiryTimeUTC - expiryBuffer);
|
|
144
138
|
}
|
|
145
139
|
|
|
@@ -158,13 +152,11 @@ async function authorizeGoogleDriveClient(forceReauth = false) {
|
|
|
158
152
|
}
|
|
159
153
|
}
|
|
160
154
|
|
|
161
|
-
// If not forcing reauth, try to load existing credentials
|
|
162
155
|
if (!forceReauth) {
|
|
163
156
|
let client = await loadSavedCredentialsIfExist();
|
|
164
157
|
if (client) {
|
|
165
158
|
const credentials = JSON.parse(fs.readFileSync(TOKEN_PATH));
|
|
166
159
|
|
|
167
|
-
// Ensure we're using the client's credentials which may have been updated
|
|
168
160
|
const clientCredentials = client.credentials || credentials;
|
|
169
161
|
|
|
170
162
|
if (await isTokenExpired(clientCredentials)) {
|
|
@@ -172,21 +164,18 @@ async function authorizeGoogleDriveClient(forceReauth = false) {
|
|
|
172
164
|
if (client) {
|
|
173
165
|
return client;
|
|
174
166
|
}
|
|
175
|
-
// If refresh failed, fall through to full reauth
|
|
176
167
|
} else {
|
|
177
168
|
return client;
|
|
178
169
|
}
|
|
179
170
|
}
|
|
180
171
|
}
|
|
181
172
|
|
|
182
|
-
// Perform full authentication
|
|
183
173
|
client = await authenticate({
|
|
184
174
|
scopes: SCOPES,
|
|
185
175
|
keyfilePath: CREDENTIALS_PATH,
|
|
186
176
|
});
|
|
187
177
|
|
|
188
|
-
|
|
189
|
-
if (client && client.credentials) {
|
|
178
|
+
if (client && client.credentials && existsSync(path.dirname(TOKEN_PATH))) {
|
|
190
179
|
const credentialsToSave = {
|
|
191
180
|
storage: "google-drive",
|
|
192
181
|
...client.credentials
|
|
@@ -206,7 +195,7 @@ async function init(storage) {
|
|
|
206
195
|
setupFilesAndFolders(metaData, credentials);
|
|
207
196
|
break;
|
|
208
197
|
case "google-drive":
|
|
209
|
-
const client = await authorizeGoogleDriveClient(true);
|
|
198
|
+
const client = await authorizeGoogleDriveClient(true);
|
|
210
199
|
credentials = { storage: "google-drive", ...client.credentials };
|
|
211
200
|
setupFilesAndFolders(metaData, credentials);
|
|
212
201
|
break;
|
|
@@ -264,6 +253,7 @@ function add(listOfFiles) {
|
|
|
264
253
|
checkIfDorkyProject();
|
|
265
254
|
console.log("Adding files to stage-1 to push to storage");
|
|
266
255
|
const metaData = JSON.parse(fs.readFileSync(".dorky/metadata.json"));
|
|
256
|
+
const addedFiles = [];
|
|
267
257
|
listOfFiles.forEach((file) => {
|
|
268
258
|
if (!fs.existsSync(file)) {
|
|
269
259
|
console.log(chalk.red(`File ${file} does not exist.`));
|
|
@@ -271,13 +261,20 @@ function add(listOfFiles) {
|
|
|
271
261
|
}
|
|
272
262
|
const fileContents = fs.readFileSync(file);
|
|
273
263
|
const fileType = mimeTypes.lookup(file);
|
|
264
|
+
const newHash = md5(fileContents);
|
|
265
|
+
const existingEntry = metaData["stage-1-files"][file];
|
|
266
|
+
if (existingEntry && existingEntry.hash === newHash) {
|
|
267
|
+
console.log(chalk.yellow(`File ${file} has no changes, skipping.`));
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
274
270
|
metaData["stage-1-files"][file] = {
|
|
275
271
|
"mime-type": fileType ? fileType : "application/octet-stream",
|
|
276
|
-
"hash":
|
|
272
|
+
"hash": newHash
|
|
277
273
|
};
|
|
274
|
+
addedFiles.push(file);
|
|
278
275
|
});
|
|
279
276
|
fs.writeFileSync(".dorky/metadata.json", JSON.stringify(metaData, null, 2));
|
|
280
|
-
|
|
277
|
+
addedFiles.forEach((file) => console.log(chalk.green(`Added ${file} to stage-1.`)));
|
|
281
278
|
}
|
|
282
279
|
|
|
283
280
|
function rm(listOfFiles) {
|
|
@@ -319,7 +316,7 @@ async function checkCredentials() {
|
|
|
319
316
|
} else {
|
|
320
317
|
try {
|
|
321
318
|
let credentials;
|
|
322
|
-
const client = await authorizeGoogleDriveClient(true);
|
|
319
|
+
const client = await authorizeGoogleDriveClient(true);
|
|
323
320
|
credentials = { storage: "google-drive", ...client.credentials };
|
|
324
321
|
fs.writeFileSync(".dorky/credentials.json", JSON.stringify(credentials, null, 2));
|
|
325
322
|
console.log(chalk.green("Credentials saved in .dorky/credentials.json"));
|
|
@@ -430,9 +427,8 @@ async function pushToGoogleDrive(files) {
|
|
|
430
427
|
return parentId;
|
|
431
428
|
}
|
|
432
429
|
console.log("Uploading to google drive");
|
|
433
|
-
const client = await authorizeGoogleDriveClient(false);
|
|
430
|
+
const client = await authorizeGoogleDriveClient(false);
|
|
434
431
|
|
|
435
|
-
// Update credentials file with potentially refreshed token
|
|
436
432
|
const credentialsToSave = {
|
|
437
433
|
storage: "google-drive",
|
|
438
434
|
...client.credentials
|
|
@@ -521,9 +517,8 @@ async function pullFromGoogleDrive(files) {
|
|
|
521
517
|
return { name: file, ...files[file] };
|
|
522
518
|
});
|
|
523
519
|
|
|
524
|
-
const client = await authorizeGoogleDriveClient(false);
|
|
520
|
+
const client = await authorizeGoogleDriveClient(false);
|
|
525
521
|
|
|
526
|
-
// Update credentials file with potentially refreshed token
|
|
527
522
|
const credentialsToSave = {
|
|
528
523
|
storage: "google-drive",
|
|
529
524
|
...client.credentials
|
package/package.json
CHANGED
package/web-app/README.md
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
# Getting Started with Create React App
|
|
2
|
-
|
|
3
|
-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
|
4
|
-
|
|
5
|
-
## Available Scripts
|
|
6
|
-
|
|
7
|
-
In the project directory, you can run:
|
|
8
|
-
|
|
9
|
-
### `npm start`
|
|
10
|
-
|
|
11
|
-
Runs the app in the development mode.\
|
|
12
|
-
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
|
|
13
|
-
|
|
14
|
-
The page will reload when you make changes.\
|
|
15
|
-
You may also see any lint errors in the console.
|
|
16
|
-
|
|
17
|
-
### `npm test`
|
|
18
|
-
|
|
19
|
-
Launches the test runner in the interactive watch mode.\
|
|
20
|
-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
|
21
|
-
|
|
22
|
-
### `npm run build`
|
|
23
|
-
|
|
24
|
-
Builds the app for production to the `build` folder.\
|
|
25
|
-
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
26
|
-
|
|
27
|
-
The build is minified and the filenames include the hashes.\
|
|
28
|
-
Your app is ready to be deployed!
|
|
29
|
-
|
|
30
|
-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
|
31
|
-
|
|
32
|
-
### `npm run eject`
|
|
33
|
-
|
|
34
|
-
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
|
|
35
|
-
|
|
36
|
-
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
|
37
|
-
|
|
38
|
-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
|
|
39
|
-
|
|
40
|
-
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
|
|
41
|
-
|
|
42
|
-
## Learn More
|
|
43
|
-
|
|
44
|
-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
|
45
|
-
|
|
46
|
-
To learn React, check out the [React documentation](https://reactjs.org/).
|
|
47
|
-
|
|
48
|
-
### Code Splitting
|
|
49
|
-
|
|
50
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
|
|
51
|
-
|
|
52
|
-
### Analyzing the Bundle Size
|
|
53
|
-
|
|
54
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
|
|
55
|
-
|
|
56
|
-
### Making a Progressive Web App
|
|
57
|
-
|
|
58
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
|
|
59
|
-
|
|
60
|
-
### Advanced Configuration
|
|
61
|
-
|
|
62
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
|
|
63
|
-
|
|
64
|
-
### Deployment
|
|
65
|
-
|
|
66
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
|
|
67
|
-
|
|
68
|
-
### `npm run build` fails to minify
|
|
69
|
-
|
|
70
|
-
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
|