@tenonhq/sincronia-core 0.0.68 → 0.0.71

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/dist/wizard.js CHANGED
@@ -1,85 +1,12 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
38
5
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.startWizard = startWizard;
40
6
  exports.getLoginInfo = getLoginInfo;
41
7
  exports.setupDotEnv = setupDotEnv;
42
8
  const inquirer_1 = __importDefault(require("inquirer"));
43
- const ConfigManager = __importStar(require("./config"));
44
- const AppUtils = __importStar(require("./appUtils"));
45
- const fs_1 = __importDefault(require("fs"));
46
- const fsp = fs_1.default.promises;
47
- const Logger_1 = require("./Logger");
48
- const path_1 = __importDefault(require("path"));
49
- const snClient_1 = require("./snClient");
50
- async function startWizard() {
51
- let loginAnswers = await getLoginInfo();
52
- try {
53
- let { username, password, instance } = loginAnswers;
54
- let instanceUrl = instance.replace("https://", "").replace("http://", "");
55
- if (!instanceUrl.endsWith("/")) {
56
- instanceUrl += `/`;
57
- }
58
- const client = (0, snClient_1.snClient)(instanceUrl, username, password);
59
- const apps = await (0, snClient_1.unwrapSNResponse)(client.getAppList());
60
- await setupDotEnv(loginAnswers);
61
- let hasConfig = await checkConfig();
62
- if (!hasConfig) {
63
- Logger_1.logger.info("Generating config...");
64
- await writeDefaultConfig(hasConfig);
65
- }
66
- let man = ConfigManager.getManifest(true);
67
- if (!man) {
68
- let selectedApp = await showAppList(apps);
69
- if (!selectedApp) {
70
- return;
71
- }
72
- Logger_1.logger.info("Downloading app...");
73
- await downloadApp(loginAnswers, selectedApp);
74
- }
75
- Logger_1.logger.success("You are all set up 👍 Try running 'npx sinc dev' to begin development mode.");
76
- await ConfigManager.loadConfigs();
77
- }
78
- catch (e) {
79
- Logger_1.logger.error("Failed to setup application. Check to see that your credentials are correct and you have the update set installed on your instance.");
80
- return;
81
- }
82
- }
9
+ const FileUtils_1 = require("./FileUtils");
83
10
  async function getLoginInfo() {
84
11
  return await inquirer_1.default.prompt([
85
12
  {
@@ -99,80 +26,15 @@ async function getLoginInfo() {
99
26
  },
100
27
  ]);
101
28
  }
102
- async function checkConfig() {
103
- try {
104
- let checkConfig = ConfigManager.checkConfigPath();
105
- if (!checkConfig) {
106
- return false;
107
- }
108
- await fsp.access(checkConfig, fs_1.default.constants.F_OK);
109
- return true;
110
- }
111
- catch (e) {
112
- return false;
113
- }
114
- }
115
29
  async function setupDotEnv(answers) {
116
- let data = `SN_USER=${answers.username}
117
- SN_PASSWORD=${answers.password}
118
- SN_INSTANCE=${answers.instance}
119
- `;
120
30
  process.env.SN_USER = answers.username;
121
31
  process.env.SN_PASSWORD = answers.password;
122
32
  process.env.SN_INSTANCE = answers.instance;
123
- try {
124
- await fsp.writeFile(ConfigManager.getEnvPath(), data);
125
- }
126
- catch (e) {
127
- throw e;
128
- }
129
- }
130
- async function writeDefaultConfig(hasConfig) {
131
- try {
132
- let pth;
133
- if (hasConfig)
134
- pth = ConfigManager.getConfigPath();
135
- else
136
- pth = path_1.default.join(process.cwd(), "sinc.config.js");
137
- if (pth) {
138
- await fsp.writeFile(pth, ConfigManager.getDefaultConfigFile());
139
- }
140
- }
141
- catch (e) {
142
- throw e;
143
- }
144
- }
145
- async function showAppList(apps) {
146
- let appSelection = await inquirer_1.default.prompt([
147
- {
148
- type: "list",
149
- name: "app",
150
- message: "Which app would you like to work with?",
151
- choices: apps.map((app) => {
152
- return {
153
- name: `${app.displayName}(${app.scope})`,
154
- value: app.scope,
155
- short: app.displayName,
156
- };
157
- }),
158
- },
159
- ]);
160
- return appSelection.app;
161
- }
162
- async function downloadApp(answers, scope) {
163
- try {
164
- const client = (0, snClient_1.defaultClient)();
165
- const config = ConfigManager.getConfig();
166
- const man = await (0, snClient_1.unwrapSNResponse)(client.getManifest(scope, config, true));
167
- await AppUtils.processManifest(man);
168
- }
169
- catch (e) {
170
- let message;
171
- if (e instanceof Error)
172
- message = e.message;
173
- else
174
- message = String(e);
175
- Logger_1.logger.error(message);
176
- throw new Error("Failed to download files!");
177
- }
33
+ (0, FileUtils_1.writeEnvVars)({
34
+ vars: [
35
+ { key: "SN_USER", value: answers.username },
36
+ { key: "SN_PASSWORD", value: answers.password },
37
+ { key: "SN_INSTANCE", value: answers.instance },
38
+ ],
39
+ });
178
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenonhq/sincronia-core",
3
- "version": "0.0.68",
3
+ "version": "0.0.71",
4
4
  "description": "Next-gen file syncer",
5
5
  "license": "GPL-3.0",
6
6
  "main": "./dist/index.js",
@@ -39,7 +39,6 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@tenonhq/sincronia-clickup": "^0.0.1",
42
- "@tenonhq/sincronia-core": "file:",
43
42
  "@tenonhq/sincronia-schema": "^0.0.1",
44
43
  "axios": "^1.5.1",
45
44
  "axios-cookiejar-support": "^4.0.7",