@dittowords/cli 3.10.1 → 4.0.0
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 +125 -36
- package/bin/add-project.js +101 -33
- package/bin/add-project.js.map +1 -1
- package/bin/api.js +49 -15
- package/bin/api.js.map +1 -1
- package/bin/component-folders.js +56 -7
- package/bin/component-folders.js.map +1 -1
- package/bin/config.js +206 -170
- package/bin/config.js.map +1 -1
- package/bin/config.test.js +92 -0
- package/bin/config.test.js.map +1 -0
- package/bin/consts.js +64 -18
- package/bin/consts.js.map +1 -1
- package/bin/ditto.js +250 -200
- package/bin/ditto.js.map +1 -1
- package/bin/generate-suggestions.js +155 -78
- package/bin/generate-suggestions.js.map +1 -1
- package/bin/generate-suggestions.test.js +189 -0
- package/bin/generate-suggestions.test.js.map +1 -0
- package/bin/http/fetchComponentFolders.js +60 -8
- package/bin/http/fetchComponentFolders.js.map +1 -1
- package/bin/http/fetchComponents.js +65 -18
- package/bin/http/fetchComponents.js.map +1 -1
- package/bin/http/fetchVariants.js +74 -14
- package/bin/http/fetchVariants.js.map +1 -1
- package/bin/http/importComponents.js +100 -49
- package/bin/http/importComponents.js.map +1 -1
- package/bin/importComponents.js +61 -10
- package/bin/importComponents.js.map +1 -1
- package/bin/init/init.js +120 -44
- package/bin/init/init.js.map +1 -1
- package/bin/init/project.js +160 -83
- package/bin/init/project.js.map +1 -1
- package/bin/init/project.test.js +49 -0
- package/bin/init/project.test.js.map +1 -0
- package/bin/init/token.js +134 -74
- package/bin/init/token.js.map +1 -1
- package/bin/init/token.test.js +69 -0
- package/bin/init/token.test.js.map +1 -0
- package/bin/output.js +72 -30
- package/bin/output.js.map +1 -1
- package/bin/pull.js +424 -213
- package/bin/pull.js.map +1 -1
- package/bin/pull.test.js +410 -0
- package/bin/pull.test.js.map +1 -0
- package/bin/remove-project.js +91 -27
- package/bin/remove-project.js.map +1 -1
- package/bin/replace.js +140 -100
- package/bin/replace.js.map +1 -1
- package/bin/replace.test.js +155 -0
- package/bin/replace.test.js.map +1 -0
- package/bin/sentry-test.js.map +1 -0
- package/bin/types.js +20 -2
- package/bin/types.js.map +1 -1
- package/bin/utils/cleanFileName.js +32 -8
- package/bin/utils/cleanFileName.js.map +1 -1
- package/bin/utils/createSentryContext.js +43 -0
- package/bin/utils/createSentryContext.js.map +1 -0
- package/bin/utils/generateJsDriver.js +114 -51
- package/bin/utils/generateJsDriver.js.map +1 -1
- package/bin/utils/getSelectedProjects.js +58 -52
- package/bin/utils/getSelectedProjects.js.map +1 -1
- package/bin/utils/processMetaOption.js +36 -11
- package/bin/utils/processMetaOption.js.map +1 -1
- package/bin/utils/processMetaOption.test.js +45 -0
- package/bin/utils/processMetaOption.test.js.map +1 -0
- package/bin/utils/projectsToText.js +52 -19
- package/bin/utils/projectsToText.js.map +1 -1
- package/bin/utils/promptForProject.js +89 -36
- package/bin/utils/promptForProject.js.map +1 -1
- package/bin/utils/quit.js +36 -7
- package/bin/utils/quit.js.map +1 -1
- package/bin/utils/sourcesToText.js +51 -19
- package/bin/utils/sourcesToText.js.map +1 -1
- package/etsc.config.js +13 -0
- package/lib/config.ts +27 -8
- package/lib/ditto.ts +6 -0
- package/lib/init/project.ts +3 -3
- package/lib/pull.ts +190 -52
- package/lib/types.ts +24 -7
- package/lib/utils/createSentryContext.ts +20 -0
- package/lib/utils/generateJsDriver.ts +40 -6
- package/lib/utils/quit.ts +2 -3
- package/package.json +10 -6
- package/tsconfig.json +4 -1
- package/bin/lib/add-project.js +0 -36
- package/bin/lib/add-project.js.map +0 -1
- package/bin/lib/api.js +0 -20
- package/bin/lib/api.js.map +0 -1
- package/bin/lib/config.js +0 -202
- package/bin/lib/config.js.map +0 -1
- package/bin/lib/consts.js +0 -21
- package/bin/lib/consts.js.map +0 -1
- package/bin/lib/ditto.js +0 -121
- package/bin/lib/ditto.js.map +0 -1
- package/bin/lib/generate-suggestions.js +0 -71
- package/bin/lib/generate-suggestions.js.map +0 -1
- package/bin/lib/http/fetchComponents.js +0 -13
- package/bin/lib/http/fetchComponents.js.map +0 -1
- package/bin/lib/http/fetchVariants.js +0 -26
- package/bin/lib/http/fetchVariants.js.map +0 -1
- package/bin/lib/init/init.js +0 -50
- package/bin/lib/init/init.js.map +0 -1
- package/bin/lib/init/project.js +0 -108
- package/bin/lib/init/project.js.map +0 -1
- package/bin/lib/init/token.js +0 -91
- package/bin/lib/init/token.js.map +0 -1
- package/bin/lib/output.js +0 -34
- package/bin/lib/output.js.map +0 -1
- package/bin/lib/pull.js +0 -264
- package/bin/lib/pull.js.map +0 -1
- package/bin/lib/remove-project.js +0 -35
- package/bin/lib/remove-project.js.map +0 -1
- package/bin/lib/replace.js +0 -107
- package/bin/lib/replace.js.map +0 -1
- package/bin/lib/types.js +0 -3
- package/bin/lib/types.js.map +0 -1
- package/bin/lib/utils/cleanFileName.js +0 -11
- package/bin/lib/utils/cleanFileName.js.map +0 -1
- package/bin/lib/utils/generateJsDriver.js +0 -56
- package/bin/lib/utils/generateJsDriver.js.map +0 -1
- package/bin/lib/utils/getSelectedProjects.js +0 -61
- package/bin/lib/utils/getSelectedProjects.js.map +0 -1
- package/bin/lib/utils/processMetaOption.js +0 -15
- package/bin/lib/utils/processMetaOption.js.map +0 -1
- package/bin/lib/utils/projectsToText.js +0 -25
- package/bin/lib/utils/projectsToText.js.map +0 -1
- package/bin/lib/utils/promptForProject.js +0 -43
- package/bin/lib/utils/promptForProject.js.map +0 -1
- package/bin/lib/utils/quit.js +0 -10
- package/bin/lib/utils/quit.js.map +0 -1
- package/bin/lib/utils/sourcesToText.js +0 -25
- package/bin/lib/utils/sourcesToText.js.map +0 -1
- package/bin/package.json +0 -76
package/bin/init/token.js
CHANGED
|
@@ -1,91 +1,151 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8ea35454-3a68-5e02-b127-d1129433ec18")}catch(e){}}();
|
|
3
|
+
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
4
13
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
+
var __async = (__this, __arguments, generator) => {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
var fulfilled = (value) => {
|
|
34
|
+
try {
|
|
35
|
+
step(generator.next(value));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var rejected = (value) => {
|
|
41
|
+
try {
|
|
42
|
+
step(generator.throw(value));
|
|
43
|
+
} catch (e) {
|
|
44
|
+
reject(e);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
48
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
var token_exports = {};
|
|
52
|
+
__export(token_exports, {
|
|
53
|
+
collectAndSaveToken: () => collectAndSaveToken,
|
|
54
|
+
default: () => token_default,
|
|
55
|
+
needsToken: () => needsToken
|
|
56
|
+
});
|
|
57
|
+
module.exports = __toCommonJS(token_exports);
|
|
58
|
+
var import_fs = __toESM(require("fs"));
|
|
59
|
+
var import_chalk = __toESM(require("chalk"));
|
|
60
|
+
var import_enquirer = require("enquirer");
|
|
61
|
+
var import_api = require("../api");
|
|
62
|
+
var import_consts = __toESM(require("../consts"));
|
|
63
|
+
var import_output = __toESM(require("../output"));
|
|
64
|
+
var import_config = __toESM(require("../config"));
|
|
65
|
+
var import_quit = require("../utils/quit");
|
|
66
|
+
const needsToken = (configFile, host = import_consts.default.API_HOST) => {
|
|
67
|
+
if (import_config.default.getTokenFromEnv()) {
|
|
26
68
|
return false;
|
|
69
|
+
}
|
|
70
|
+
const file = configFile || import_consts.default.CONFIG_FILE;
|
|
71
|
+
if (!import_fs.default.existsSync(file))
|
|
72
|
+
return true;
|
|
73
|
+
const configData = import_config.default.readGlobalConfigData(file);
|
|
74
|
+
if (!configData[import_config.default.justTheHost(host)] || configData[import_config.default.justTheHost(host)][0].token === "")
|
|
75
|
+
return true;
|
|
76
|
+
return false;
|
|
27
77
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const axios = (0, api_1.createApiClient)(token);
|
|
78
|
+
function checkToken(token) {
|
|
79
|
+
return __async(this, null, function* () {
|
|
80
|
+
const axios = (0, import_api.createApiClient)(token);
|
|
32
81
|
const endpoint = "/token-check";
|
|
33
82
|
let resOrError;
|
|
34
83
|
try {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
84
|
+
resOrError = yield axios.get(endpoint).catch((error) => {
|
|
85
|
+
if (error.code === "ENOTFOUND") {
|
|
86
|
+
return import_output.default.errorText(
|
|
87
|
+
`Can't connect to API: ${import_output.default.url(error.hostname)}`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
if (error.response.status === 401 || error.response.status === 404) {
|
|
91
|
+
return import_output.default.errorText(
|
|
92
|
+
"This API key isn't valid. Please try another."
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
return import_output.default.warnText("We're having trouble reaching the Ditto API.");
|
|
96
|
+
});
|
|
97
|
+
} catch (e) {
|
|
98
|
+
import_output.default.errorText(e);
|
|
99
|
+
import_output.default.errorText("Sorry! We're having trouble reaching the Ditto API.");
|
|
48
100
|
}
|
|
49
101
|
if (typeof resOrError === "string") {
|
|
50
|
-
|
|
102
|
+
return resOrError;
|
|
51
103
|
}
|
|
52
|
-
if (resOrError
|
|
53
|
-
|
|
104
|
+
if ((resOrError == null ? void 0 : resOrError.status) === 200) {
|
|
105
|
+
return true;
|
|
54
106
|
}
|
|
55
|
-
return
|
|
107
|
+
return import_output.default.errorText("This API key isn't valid. Please try another.");
|
|
108
|
+
});
|
|
56
109
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
110
|
+
function collectToken(message) {
|
|
111
|
+
return __async(this, null, function* () {
|
|
112
|
+
const blue = import_output.default.info;
|
|
113
|
+
const apiUrl = import_output.default.url("https://app.dittowords.com/account/user");
|
|
60
114
|
const breadcrumbs = `${blue("User")}`;
|
|
61
|
-
const tokenDescription = message ||
|
|
62
|
-
|
|
115
|
+
const tokenDescription = message || `To get started, you'll need your Ditto API key. You can find this at: ${apiUrl} > ${breadcrumbs} under "${import_chalk.default.bold(
|
|
116
|
+
"API Keys"
|
|
117
|
+
)}".`;
|
|
63
118
|
console.log(tokenDescription);
|
|
64
|
-
const response =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
119
|
+
const response = yield (0, import_enquirer.prompt)({
|
|
120
|
+
type: "input",
|
|
121
|
+
name: "token",
|
|
122
|
+
message: "What is your API key?",
|
|
123
|
+
validate: (token) => checkToken(token)
|
|
69
124
|
});
|
|
70
125
|
return response.token;
|
|
126
|
+
});
|
|
71
127
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
exports
|
|
90
|
-
|
|
91
|
-
|
|
128
|
+
const collectAndSaveToken = (message = null) => __async(void 0, null, function* () {
|
|
129
|
+
try {
|
|
130
|
+
const token = yield collectToken(message);
|
|
131
|
+
console.log(
|
|
132
|
+
`Thanks for authenticating. We'll save the key to: ${import_output.default.info(
|
|
133
|
+
import_consts.default.CONFIG_FILE
|
|
134
|
+
)}`
|
|
135
|
+
);
|
|
136
|
+
import_output.default.nl();
|
|
137
|
+
import_config.default.saveToken(import_consts.default.CONFIG_FILE, import_consts.default.API_HOST, token);
|
|
138
|
+
return token;
|
|
139
|
+
} catch (error) {
|
|
140
|
+
(0, import_quit.quit)("API token was not saved");
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
var token_default = { needsToken, collectAndSaveToken };
|
|
144
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
145
|
+
0 && (module.exports = {
|
|
146
|
+
collectAndSaveToken,
|
|
147
|
+
needsToken
|
|
148
|
+
});
|
|
149
|
+
//# sourceMappingURL=token.js.map
|
|
150
|
+
|
|
151
|
+
//# debugId=8ea35454-3a68-5e02-b127-d1129433ec18
|
package/bin/init/token.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../lib/init/token.ts"],"sourcesContent":["import fs from \"fs\";\n\nimport chalk from \"chalk\";\n\nimport { prompt } from \"enquirer\";\n\nimport { createApiClient } from \"../api\";\nimport consts from \"../consts\";\nimport output from \"../output\";\nimport config from \"../config\";\nimport { quit } from \"../utils/quit\";\n\nexport const needsToken = (configFile?: string, host = consts.API_HOST) => {\n if (config.getTokenFromEnv()) {\n return false;\n }\n\n const file = configFile || consts.CONFIG_FILE;\n if (!fs.existsSync(file)) return true;\n const configData = config.readGlobalConfigData(file);\n if (\n !configData[config.justTheHost(host)] ||\n configData[config.justTheHost(host)][0].token === \"\"\n )\n return true;\n return false;\n};\n\n// Returns true if valid, otherwise an error message.\nasync function checkToken(token: string): Promise<any> {\n const axios = createApiClient(token);\n const endpoint = \"/token-check\";\n\n let resOrError;\n try {\n resOrError = await axios.get(endpoint).catch((error: any) => {\n if (error.code === \"ENOTFOUND\") {\n return output.errorText(\n `Can't connect to API: ${output.url(error.hostname)}`\n );\n }\n if (error.response.status === 401 || error.response.status === 404) {\n return output.errorText(\n \"This API key isn't valid. Please try another.\"\n );\n }\n return output.warnText(\"We're having trouble reaching the Ditto API.\");\n });\n } catch (e: unknown) {\n output.errorText(e as any);\n output.errorText(\"Sorry! We're having trouble reaching the Ditto API.\");\n }\n\n if (typeof resOrError === \"string\") {\n return resOrError;\n }\n\n if (resOrError?.status === 200) {\n return true;\n }\n\n return output.errorText(\"This API key isn't valid. Please try another.\");\n}\n\nasync function collectToken(message: string | null) {\n const blue = output.info;\n const apiUrl = output.url(\"https://app.dittowords.com/account/user\");\n const breadcrumbs = `${blue(\"User\")}`;\n const tokenDescription =\n message ||\n `To get started, you'll need your Ditto API key. You can find this at: ${apiUrl} > ${breadcrumbs} under \"${chalk.bold(\n \"API Keys\"\n )}\".`;\n console.log(tokenDescription);\n\n const response = await prompt<{ token: string }>({\n type: \"input\",\n name: \"token\",\n message: \"What is your API key?\",\n validate: (token) => checkToken(token),\n });\n return response.token;\n}\n\n/**\n *\n * @param {string | null} message\n * @returns\n */\nexport const collectAndSaveToken = async (message: string | null = null) => {\n try {\n const token = await collectToken(message);\n console.log(\n `Thanks for authenticating. We'll save the key to: ${output.info(\n consts.CONFIG_FILE\n )}`\n );\n output.nl();\n\n config.saveToken(consts.CONFIG_FILE, consts.API_HOST, token);\n return token;\n } catch (error) {\n quit(\"API token was not saved\");\n }\n};\n\nexport default { needsToken, collectAndSaveToken };\n"],"names":["consts","config","fs","output","chalk"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AAEf,mBAAkB;AAElB,sBAAuB;AAEvB,iBAAgC;AAChC,oBAAmB;AACnB,oBAAmB;AACnB,oBAAmB;AACnB,kBAAqB;AAEd,MAAM,aAAa,CAAC,YAAqB,OAAO,cAAAA,QAAO,aAAa;AACzE,MAAI,cAAAC,QAAO,gBAAgB,GAAG;AAC5B,WAAO;AAAA,EACT;AAEA,QAAM,OAAO,cAAc,cAAAD,QAAO;AAClC,MAAI,CAAC,UAAAE,QAAG,WAAW,IAAI;AAAG,WAAO;AACjC,QAAM,aAAa,cAAAD,QAAO,qBAAqB,IAAI;AACnD,MACE,CAAC,WAAW,cAAAA,QAAO,YAAY,IAAI,CAAC,KACpC,WAAW,cAAAA,QAAO,YAAY,IAAI,CAAC,EAAE,CAAC,EAAE,UAAU;AAElD,WAAO;AACT,SAAO;AACT;AAGA,SAAe,WAAW,OAA6B;AAAA;AACrD,UAAM,YAAQ,4BAAgB,KAAK;AACnC,UAAM,WAAW;AAEjB,QAAI;AACJ,QAAI;AACF,mBAAa,MAAM,MAAM,IAAI,QAAQ,EAAE,MAAM,CAAC,UAAe;AAC3D,YAAI,MAAM,SAAS,aAAa;AAC9B,iBAAO,cAAAE,QAAO;AAAA,YACZ,yBAAyB,cAAAA,QAAO,IAAI,MAAM,QAAQ,CAAC;AAAA,UACrD;AAAA,QACF;AACA,YAAI,MAAM,SAAS,WAAW,OAAO,MAAM,SAAS,WAAW,KAAK;AAClE,iBAAO,cAAAA,QAAO;AAAA,YACZ;AAAA,UACF;AAAA,QACF;AACA,eAAO,cAAAA,QAAO,SAAS,8CAA8C;AAAA,MACvE,CAAC;AAAA,IACH,SAAS,GAAY;AACnB,oBAAAA,QAAO,UAAU,CAAQ;AACzB,oBAAAA,QAAO,UAAU,qDAAqD;AAAA,IACxE;AAEA,QAAI,OAAO,eAAe,UAAU;AAClC,aAAO;AAAA,IACT;AAEA,SAAI,yCAAY,YAAW,KAAK;AAC9B,aAAO;AAAA,IACT;AAEA,WAAO,cAAAA,QAAO,UAAU,+CAA+C;AAAA,EACzE;AAAA;AAEA,SAAe,aAAa,SAAwB;AAAA;AAClD,UAAM,OAAO,cAAAA,QAAO;AACpB,UAAM,SAAS,cAAAA,QAAO,IAAI,yCAAyC;AACnE,UAAM,cAAc,GAAG,KAAK,MAAM,CAAC;AACnC,UAAM,mBACJ,WACA,yEAAyE,MAAM,MAAM,WAAW,WAAW,aAAAC,QAAM;AAAA,MAC/G;AAAA,IACF,CAAC;AACH,YAAQ,IAAI,gBAAgB;AAE5B,UAAM,WAAW,UAAM,wBAA0B;AAAA,MAC/C,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS;AAAA,MACT,UAAU,CAAC,UAAU,WAAW,KAAK;AAAA,IACvC,CAAC;AACD,WAAO,SAAS;AAAA,EAClB;AAAA;AAOO,MAAM,sBAAsB,CAAO,UAAyB,SAAS;AAC1E,MAAI;AACF,UAAM,QAAQ,MAAM,aAAa,OAAO;AACxC,YAAQ;AAAA,MACN,sDAAsD,cAAAD,QAAO;AAAA,QAC3D,cAAAH,QAAO;AAAA,MACT,CAAC;AAAA,IACH;AACA,kBAAAG,QAAO,GAAG;AAEV,kBAAAF,QAAO,UAAU,cAAAD,QAAO,aAAa,cAAAA,QAAO,UAAU,KAAK;AAC3D,WAAO;AAAA,EACT,SAAS,OAAO;AACd,0BAAK,yBAAyB;AAAA,EAChC;AACF;AAEA,IAAO,gBAAQ,EAAE,YAAY,oBAAoB","debug_id":"8ea35454-3a68-5e02-b127-d1129433ec18"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3e9c9176-92d8-5cb0-b038-a69b199029a8")}catch(e){}}();
|
|
3
|
+
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
var import_tempy = __toESM(require("tempy"));
|
|
27
|
+
var import_config = __toESM(require("../config"));
|
|
28
|
+
var import_token = require("./token");
|
|
29
|
+
describe("needsToken()", () => {
|
|
30
|
+
it("is true if there is no config file", () => {
|
|
31
|
+
expect((0, import_token.needsToken)(import_tempy.default.file())).toBeTruthy();
|
|
32
|
+
});
|
|
33
|
+
describe("with a config file", () => {
|
|
34
|
+
let configFile;
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
configFile = import_tempy.default.writeSync("");
|
|
37
|
+
});
|
|
38
|
+
it("returns true if empty", () => {
|
|
39
|
+
expect((0, import_token.needsToken)(configFile, "testing.dittowrods.com")).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
describe("with some data", () => {
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
import_config.default.saveToken(configFile, "badtesting.dittowords.com", "faketoken");
|
|
44
|
+
});
|
|
45
|
+
it("is true if there is no entries for our API host", () => {
|
|
46
|
+
expect((0, import_token.needsToken)(configFile, "testing.dittowords.com")).toBeTruthy();
|
|
47
|
+
});
|
|
48
|
+
it("is false if we have a token listed", () => {
|
|
49
|
+
import_config.default.saveToken(configFile, "testing.dittowords.com", "faketoken");
|
|
50
|
+
expect((0, import_token.needsToken)(configFile, "testing.dittowords.com")).toBeFalsy();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
it("is true if there is no token listed", () => {
|
|
54
|
+
const configNoToken = "../../testing/fixtures/ditto-config-no-token";
|
|
55
|
+
expect((0, import_token.needsToken)(configNoToken, "testing.dittowords.com")).toBeTruthy();
|
|
56
|
+
});
|
|
57
|
+
it("is strips the protocol when writing an entry", () => {
|
|
58
|
+
import_config.default.saveToken(
|
|
59
|
+
configFile,
|
|
60
|
+
"https://testing.dittowords.com",
|
|
61
|
+
"faketoken"
|
|
62
|
+
);
|
|
63
|
+
expect((0, import_token.needsToken)(configFile, "testing.dittowords.com")).toBeFalsy();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=token.test.js.map
|
|
68
|
+
|
|
69
|
+
//# debugId=3e9c9176-92d8-5cb0-b038-a69b199029a8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../lib/init/token.test.ts"],"sourcesContent":["import tempy from \"tempy\";\n\nimport config from \"../config\";\nimport { needsToken } from \"./token\";\n\ndescribe(\"needsToken()\", () => {\n it(\"is true if there is no config file\", () => {\n expect(needsToken(tempy.file())).toBeTruthy();\n });\n\n describe(\"with a config file\", () => {\n let configFile;\n\n beforeEach(() => {\n configFile = tempy.writeSync(\"\");\n });\n\n it(\"returns true if empty\", () => {\n expect(needsToken(configFile, \"testing.dittowrods.com\")).toBeTruthy();\n });\n\n describe(\"with some data\", () => {\n beforeEach(() => {\n config.saveToken(configFile, \"badtesting.dittowords.com\", \"faketoken\");\n });\n\n it(\"is true if there is no entries for our API host\", () => {\n expect(needsToken(configFile, \"testing.dittowords.com\")).toBeTruthy();\n });\n\n it(\"is false if we have a token listed\", () => {\n config.saveToken(configFile, \"testing.dittowords.com\", \"faketoken\");\n expect(needsToken(configFile, \"testing.dittowords.com\")).toBeFalsy();\n });\n });\n\n it(\"is true if there is no token listed\", () => {\n const configNoToken = \"../../testing/fixtures/ditto-config-no-token\";\n expect(needsToken(configNoToken, \"testing.dittowords.com\")).toBeTruthy();\n });\n\n it(\"is strips the protocol when writing an entry\", () => {\n config.saveToken(\n configFile,\n \"https://testing.dittowords.com\",\n \"faketoken\"\n );\n expect(needsToken(configFile, \"testing.dittowords.com\")).toBeFalsy();\n });\n });\n});\n"],"names":["tempy","config"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mBAAkB;AAElB,oBAAmB;AACnB,mBAA2B;AAE3B,SAAS,gBAAgB,MAAM;AAC7B,KAAG,sCAAsC,MAAM;AAC7C,eAAO,yBAAW,aAAAA,QAAM,KAAK,CAAC,CAAC,EAAE,WAAW;AAAA,EAC9C,CAAC;AAED,WAAS,sBAAsB,MAAM;AACnC,QAAI;AAEJ,eAAW,MAAM;AACf,mBAAa,aAAAA,QAAM,UAAU,EAAE;AAAA,IACjC,CAAC;AAED,OAAG,yBAAyB,MAAM;AAChC,iBAAO,yBAAW,YAAY,wBAAwB,CAAC,EAAE,WAAW;AAAA,IACtE,CAAC;AAED,aAAS,kBAAkB,MAAM;AAC/B,iBAAW,MAAM;AACf,sBAAAC,QAAO,UAAU,YAAY,6BAA6B,WAAW;AAAA,MACvE,CAAC;AAED,SAAG,mDAAmD,MAAM;AAC1D,mBAAO,yBAAW,YAAY,wBAAwB,CAAC,EAAE,WAAW;AAAA,MACtE,CAAC;AAED,SAAG,sCAAsC,MAAM;AAC7C,sBAAAA,QAAO,UAAU,YAAY,0BAA0B,WAAW;AAClE,mBAAO,yBAAW,YAAY,wBAAwB,CAAC,EAAE,UAAU;AAAA,MACrE,CAAC;AAAA,IACH,CAAC;AAED,OAAG,uCAAuC,MAAM;AAC9C,YAAM,gBAAgB;AACtB,iBAAO,yBAAW,eAAe,wBAAwB,CAAC,EAAE,WAAW;AAAA,IACzE,CAAC;AAED,OAAG,gDAAgD,MAAM;AACvD,oBAAAA,QAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,iBAAO,yBAAW,YAAY,wBAAwB,CAAC,EAAE,UAAU;AAAA,IACrE,CAAC;AAAA,EACH,CAAC;AACH,CAAC","debug_id":"3e9c9176-92d8-5cb0-b038-a69b199029a8"}
|
package/bin/output.js
CHANGED
|
@@ -1,34 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="55eb6917-59ee-5f13-a6ca-cba2b2ea82dc")}catch(e){}}();
|
|
3
|
+
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
4
13
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
exports
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
+
var output_exports = {};
|
|
32
|
+
__export(output_exports, {
|
|
33
|
+
default: () => output_default,
|
|
34
|
+
errorText: () => errorText,
|
|
35
|
+
info: () => info,
|
|
36
|
+
nl: () => nl,
|
|
37
|
+
subtle: () => subtle,
|
|
38
|
+
success: () => success,
|
|
39
|
+
url: () => url,
|
|
40
|
+
warnText: () => warnText,
|
|
41
|
+
write: () => write
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(output_exports);
|
|
44
|
+
var import_chalk = __toESM(require("chalk"));
|
|
45
|
+
const errorText = (msg) => import_chalk.default.magenta(msg);
|
|
46
|
+
const warnText = (msg) => import_chalk.default.yellow(msg);
|
|
47
|
+
const info = (msg) => import_chalk.default.blueBright(msg);
|
|
48
|
+
const success = (msg) => import_chalk.default.green(msg);
|
|
49
|
+
const url = (msg) => import_chalk.default.blueBright.underline(msg);
|
|
50
|
+
const subtle = (msg) => import_chalk.default.grey(msg);
|
|
51
|
+
const write = (msg) => import_chalk.default.white(msg);
|
|
22
52
|
const nl = () => console.log("\n");
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
nl: exports.nl,
|
|
53
|
+
var output_default = {
|
|
54
|
+
errorText,
|
|
55
|
+
warnText,
|
|
56
|
+
info,
|
|
57
|
+
success,
|
|
58
|
+
url,
|
|
59
|
+
subtle,
|
|
60
|
+
write,
|
|
61
|
+
nl
|
|
33
62
|
};
|
|
34
|
-
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
errorText,
|
|
66
|
+
info,
|
|
67
|
+
nl,
|
|
68
|
+
subtle,
|
|
69
|
+
success,
|
|
70
|
+
url,
|
|
71
|
+
warnText,
|
|
72
|
+
write
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=output.js.map
|
|
75
|
+
|
|
76
|
+
//# debugId=55eb6917-59ee-5f13-a6ca-cba2b2ea82dc
|
package/bin/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../lib/output.ts"],"sourcesContent":["import chalk from \"chalk\";\n\nexport const errorText = (msg: string) => chalk.magenta(msg);\nexport const warnText = (msg: string) => chalk.yellow(msg);\nexport const info = (msg: string) => chalk.blueBright(msg);\nexport const success = (msg: string) => chalk.green(msg);\nexport const url = (msg: string) => chalk.blueBright.underline(msg);\nexport const subtle = (msg: string) => chalk.grey(msg);\nexport const write = (msg: string) => chalk.white(msg);\nexport const nl = () => console.log(\"\\n\");\n\nexport default {\n errorText,\n warnText,\n info,\n success,\n url,\n subtle,\n write,\n nl,\n};\n"],"names":["chalk"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAEX,MAAM,YAAY,CAAC,QAAgB,aAAAA,QAAM,QAAQ,GAAG;AACpD,MAAM,WAAW,CAAC,QAAgB,aAAAA,QAAM,OAAO,GAAG;AAClD,MAAM,OAAO,CAAC,QAAgB,aAAAA,QAAM,WAAW,GAAG;AAClD,MAAM,UAAU,CAAC,QAAgB,aAAAA,QAAM,MAAM,GAAG;AAChD,MAAM,MAAM,CAAC,QAAgB,aAAAA,QAAM,WAAW,UAAU,GAAG;AAC3D,MAAM,SAAS,CAAC,QAAgB,aAAAA,QAAM,KAAK,GAAG;AAC9C,MAAM,QAAQ,CAAC,QAAgB,aAAAA,QAAM,MAAM,GAAG;AAC9C,MAAM,KAAK,MAAM,QAAQ,IAAI,IAAI;AAExC,IAAO,iBAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF","debug_id":"55eb6917-59ee-5f13-a6ca-cba2b2ea82dc"}
|