pinme 1.2.1 → 1.2.2-alpha.1
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 +55 -1
- package/dist/index.js +1719 -876
- package/dist/utils/getDeviceId.js +61 -0
- package/package.json +1 -1
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// bin/utils/getDeviceId.ts
|
|
31
|
+
var getDeviceId_exports = {};
|
|
32
|
+
__export(getDeviceId_exports, {
|
|
33
|
+
getDeviceId: () => getDeviceId
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(getDeviceId_exports);
|
|
36
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
37
|
+
var import_path = __toESM(require("path"));
|
|
38
|
+
var import_os = __toESM(require("os"));
|
|
39
|
+
var import_uuid = require("uuid");
|
|
40
|
+
function getDeviceId() {
|
|
41
|
+
const configDir = import_path.default.join(import_os.default.homedir(), ".pinme");
|
|
42
|
+
const configFile = import_path.default.join(configDir, "device-id");
|
|
43
|
+
if (!import_fs_extra.default.existsSync(configDir)) {
|
|
44
|
+
import_fs_extra.default.mkdirSync(configDir, { recursive: true });
|
|
45
|
+
}
|
|
46
|
+
if (import_fs_extra.default.existsSync(configFile)) {
|
|
47
|
+
const existingDeviceId = import_fs_extra.default.readFileSync(configFile, "utf8").trim();
|
|
48
|
+
console.log(`\u{1F4CD} Device ID found: ${existingDeviceId}`);
|
|
49
|
+
console.log(`\u{1F4C1} Location: ${configFile}`);
|
|
50
|
+
return existingDeviceId;
|
|
51
|
+
}
|
|
52
|
+
const deviceId = (0, import_uuid.v4)();
|
|
53
|
+
console.log(`\u{1F194} New Device ID generated: ${deviceId}`);
|
|
54
|
+
console.log(`\u{1F4C1} Saved to: ${configFile}`);
|
|
55
|
+
import_fs_extra.default.writeFileSync(configFile, deviceId);
|
|
56
|
+
return deviceId;
|
|
57
|
+
}
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
getDeviceId
|
|
61
|
+
});
|