generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
160 lines (155 loc) · 19.9 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// main.ts
var main_exports = {};
__export(main_exports, {
default: () => GenerateDiffPlugin
});
module.exports = __toCommonJS(main_exports);
var import_obsidian = require("obsidian");
// src/constants.ts
var DIRECTORY_PATH = "generate-and-diff";
var RESULTS_DIRECTORY_PATH = `${DIRECTORY_PATH}/results`;
// src/utils.ts
var GenerateDiffPluginUtils = class {
static formatDate(date) {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, "0");
const day = date.getDate().toString().padStart(2, "0");
const hours = date.getHours().toString().padStart(2, "0");
const minutes = date.getMinutes().toString().padStart(2, "0");
const seconds = date.getSeconds().toString().padStart(2, "0");
return `${year}${month}${day}-${hours}${minutes}${seconds}`;
}
static getDeviceName() {
let platform = "";
if (navigator.userAgent) {
platform = navigator.userAgent.toLowerCase();
}
if (platform.includes("windows"))
return "Windows";
if (platform.includes("macintosh")) {
if (platform.includes("mobile"))
return "iPadOS";
return "Mac";
}
if (platform.includes("linux"))
return "Linux";
if (platform.includes("iphone"))
return "iOS";
if (platform.includes("android"))
return "Android";
return "Unknown";
}
};
// main.ts
var GenerateDiffPlugin = class extends import_obsidian.Plugin {
// Try to detect device status
get syncPlugin() {
return this.app.internalPlugins.getPluginById("sync");
}
// Plugin is loaded
async onload() {
var _a;
console.log("Loading Generate and Diff " + this.manifest.version);
const syncEnabled = ((_a = this.syncPlugin) == null ? void 0 : _a.instance) != void 0;
this.device = syncEnabled ? this.syncPlugin.instance.deviceName.length > 0 ? this.syncPlugin.instance.deviceName : this.syncPlugin.instance.getDefaultDeviceName() : "Unknown";
console.debug("Generate and Diff:", this.device);
this.addCommand({
// Give it an id
id: "generate-file-list",
// Give it a name
name: "Generate File List",
// Give it a callback
callback: () => this.generateFileList()
});
this.addCommand({
// Give it an id
id: "compare-files",
// Give it a name
name: "Compare Files",
// Give it a callback
callback: () => this.compareFiles()
});
}
/* Now we move onto running the commands */
// Generate file list once the command is called
async generateFileList() {
const files = this.app.vault.getFiles();
let fileContent = "# File List\n\n";
for (const file of files) {
const fileStats = file.stat;
fileContent += `- **Path**: ${file.path} | **Last Modified**: ${new Date(fileStats.mtime).toLocaleString()}
`;
}
const deviceName = GenerateDiffPluginUtils.getDeviceName();
const timestamp = GenerateDiffPluginUtils.formatDate(new Date());
const fileName = `${DIRECTORY_PATH}/${timestamp}-${deviceName}.md`;
const directoryExists = await this.app.vault.adapter.exists(DIRECTORY_PATH);
if (!directoryExists) {
await this.app.vault.createFolder(DIRECTORY_PATH);
}
try {
await this.app.vault.create(fileName, fileContent);
console.log(`File list generated: ${fileName}`);
} catch (error) {
console.error(`Error generating file list: ${error}`);
}
}
// compare files once the command is called
async compareFiles() {
var _a, _b;
const fileList = this.app.vault.getFiles().filter((file) => file.path.startsWith(DIRECTORY_PATH + "/") && !file.path.startsWith(RESULTS_DIRECTORY_PATH + "/"));
let fileMap = {};
for (const file of fileList) {
const fileContent = await this.app.vault.read(file);
const lines = fileContent.split("\n").filter((line) => line.startsWith("- **Path**:"));
const deviceName = (_b = (_a = file.name.split("-").pop()) == null ? void 0 : _a.split(".")[0]) != null ? _b : "Unknown";
for (const line of lines) {
const filePath = line.split("|")[0].trim().replace("- **Path**: ", "");
if (!fileMap[filePath]) {
fileMap[filePath] = [];
}
fileMap[filePath].push(deviceName);
}
}
let comparisonResults = "# Comparison Results\n\n";
for (const [filePath, devices] of Object.entries(fileMap)) {
if (devices.length === 1) {
comparisonResults += `- **Path**: ${filePath} | **Exists on**: ${devices[0]}
`;
}
}
const timestamp = GenerateDiffPluginUtils.formatDate(new Date());
const resultsFileName = `${RESULTS_DIRECTORY_PATH}/${timestamp}-comparison-results.md`;
const resultsDirectoryExists = await this.app.vault.adapter.exists(RESULTS_DIRECTORY_PATH);
if (!resultsDirectoryExists) {
await this.app.vault.createFolder(RESULTS_DIRECTORY_PATH);
}
await this.app.vault.create(resultsFileName, comparisonResults);
console.log("Your results have been compared.");
}
async onunload() {
console.log("Unloading Generate and Diff");
}
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsibWFpbi50cyIsICJzcmMvY29uc3RhbnRzLnRzIiwgInNyYy91dGlscy50cyJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiLy8vIDxyZWZlcmVuY2UgcGF0aD1cInNyYy90eXBlcy50c1wiIC8+XG5cbi8vIEltcG9ydCBmcm9tIE9ic2lkaWFuIEFQSVxuaW1wb3J0IHtQbHVnaW59IGZyb20gJ29ic2lka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xpdCgnLScpLnBvcCgpPy5zcGxpdCgnLicpWzBdID8/ICdVbmtub3duJztcblxuICAgICAgICAgICAgLy8gTG9vcCB0aHJvdWdoIHRoZSBsaW5lc1xuICAgICAgICAgICAgZm9yIChjb25zdCBsaW5lIG9mIGxpbmVzKSB7XG4gICAgICAgICAgICAgICAgLy8gR2V0IHRoZSBmaWxlIHBhdGhcbiAgICAgICAgICAgICAgICBjb25zdCBmaWxlUGF0aCA9IGxpbmUuc3BsaXQoJ3wnKVswXS50cmltKCkucmVwbGFjZSgnLSAqKlBhdGgqKjogJywgJycpO1xuICAgICAgICAgICAgICAgIC8vIElmIHRoZSBmaWxlIHBhdGggZG9lc24ndCBleGlzdCBpbiB0aGUgZmlsZSBtYXAsIGNyZWF0ZSBhbiBlbXB0eSBhcnJheVxuICAgICAgICAgICAgICAgIGlmICghZmlsZU1hcFtmaWxlUGF0aF0pIHtcbiAgICAgICAgICAgICAgICAgICAgLy8gQ3JlYXRlIGFuIGVtcHR5IGFycmF5XG4gICAgICAgICAgICAgICAgICAgIGZpbGVNYXBbZmlsZVBhdGhdID0gW107XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIC8vIFB1c2ggdGhlIGRldmljZSBuYW1lIHRvIHRoZSBmaWxlIG1hcFxuICAgICAgICAgICAgICAgIGZpbGVNYXBbZmlsZVBhdGhdLnB1c2goZGV2aWNlTmFtZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAvLyBFbmQgbG9vcFxuICAgICAgICB9XG5cbiAgICAgICAgLy8gQ3JlYXRlIGEgY29tcGFyaXNvbiByZXN1bHRzXG4gICAgICAgIGxldCBjb21wYXJpc29uUmVzdWx0cyA9ICcjIENvbXBhcmlzb24gUmVzdWx0c1xcblxcbic7XG4gICAgICAgIC8vIExvb3AgdGhyb3VnaCB0aGUgZmlsZSBtYXBcbiAgICAgICAgZm9yIChjb25zdCBbZmlsZVBhdGgsIGRldmljZXNdIG9mIE9iamVjdC5lbnRyaW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