@intuned/runtime-dev 1.3.17-import.0 → 1.3.17-ws.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.
@@ -45,7 +45,7 @@ async function build(outfile, mode, template) {
45
45
  }), (0, _pluginTypescript.default)({
46
46
  tsconfig: `./intuned/${template}/tsconfig.json`
47
47
  }), (0, _pluginCommonjs.default)({
48
- include: ["node_modules/**", `intuned/${template}/**`, "dist", "../typescript-runtime/**"],
48
+ include: ["node_modules/**", `intuned/${template}/**`, "dist", "../typescript-sdk/**", "../typescript-runtime/**"],
49
49
  extensions: [".js"],
50
50
  ignoreGlobal: false,
51
51
  sourceMap: false,
@@ -21,15 +21,6 @@ const tsNodeImport = async apiName => {
21
21
  return (0, _neverthrow.ok)(imported);
22
22
  } catch (e) {
23
23
  if ("code" in e && e.code.includes("MODULE_NOT_FOUND")) {
24
- if ("requireStack" in e && Array.isArray(e.requireStack)) {
25
- const isStackTopThisFile = e.requireStack[0] === __filename;
26
- if (!isStackTopThisFile) {
27
- return (0, _neverthrow.err)({
28
- type: "other",
29
- error: e
30
- });
31
- }
32
- }
33
24
  return (0, _neverthrow.err)({
34
25
  type: "not_found"
35
26
  });
@@ -48,7 +48,7 @@ async function executeRunApiCLI({
48
48
  ...rest
49
49
  });
50
50
  } catch (error) {
51
- if (error instanceof _runApi.RunAutomationError) {
51
+ if (error instanceof _runApi.AutomationError) {
52
52
  (0, _helpers.logAutomationError)(error);
53
53
  (0, _terminal.terminal)(`^r^+Attempt ${i + 1} failed^:\n`);
54
54
  continue;
@@ -96,18 +96,24 @@ async function runSaveProject(projectName, auth) {
96
96
  ${_constants2.WORKSPACE_ID_ENV_VAR_KEY}=${workspaceId}
97
97
  ${_constants2.API_KEY_ENV_VAR_KEY}=${apiKey}`);
98
98
  (0, _terminal.terminal)(`^g^+Created .env file with project credentials.^:\n`);
99
+ return;
99
100
  }
100
101
  const envContent = await fs.readFile(dotEnvPath, "utf-8");
101
102
  const dotenvContent = dotenv.parse(envContent);
102
103
  let contentToAppend = "";
103
- if (!dotenvContent[_constants2.PROJECT_ID_ENV_VAR_KEY] || dotenvContent[_constants2.PROJECT_ID_ENV_VAR_KEY] !== projectId) {
104
- contentToAppend += `\n${_constants2.PROJECT_ID_ENV_VAR_KEY}=${projectId}`;
105
- }
106
- if (!dotenvContent[_constants2.WORKSPACE_ID_ENV_VAR_KEY]) {
107
- contentToAppend += `\n${_constants2.WORKSPACE_ID_ENV_VAR_KEY}=${workspaceId}`;
108
- }
109
- if (!dotenvContent[_constants2.API_KEY_ENV_VAR_KEY]) {
110
- contentToAppend += `\n${_constants2.API_KEY_ENV_VAR_KEY}=${apiKey}`;
104
+ const projectCredentialsEnvVars = {
105
+ [_constants2.PROJECT_ID_ENV_VAR_KEY]: projectId,
106
+ [_constants2.WORKSPACE_ID_ENV_VAR_KEY]: workspaceId,
107
+ [_constants2.API_KEY_ENV_VAR_KEY]: apiKey
108
+ };
109
+ for (const key in projectCredentialsEnvVars) {
110
+ if (dotenvContent[key] === projectCredentialsEnvVars[key]) {
111
+ continue;
112
+ }
113
+ if (dotenvContent[key]) {
114
+ (0, _terminal.terminal)(`^yWarning: Existing ${key} in .env has invalid value. Appending correct value.^:\n`);
115
+ }
116
+ contentToAppend += `${key}=${projectCredentialsEnvVars[key]}\n`;
111
117
  }
112
118
  if (contentToAppend) {
113
119
  await fs.appendFile(dotEnvPath, contentToAppend + "\n");
@@ -9,7 +9,7 @@ var _constants = require("../../../common/constants");
9
9
  var _errors = require("./errors");
10
10
  var _intunedJson = require("./intunedJson");
11
11
  async function getAuthCredentials(options) {
12
- const workspaceId = options.workspaceId || (await (0, _intunedJson.loadIntunedJson)()).workspaceId;
12
+ const workspaceId = options.workspaceId || (await (0, _intunedJson.loadIntunedJson)()).workspaceId || process.env[_constants.WORKSPACE_ID_ENV_VAR_KEY];
13
13
  const apiKey = options.apiKey || process.env[_constants.API_KEY_ENV_VAR_KEY];
14
14
  if (!workspaceId) {
15
15
  throw new _errors.CLIError(`Workspace ID is required. Please provide it via command line options or ${await (0, _intunedJson.getIntunedSettingsFileName)()}`);
@@ -3,9 +3,10 @@
3
3
  var _dotenv = _interopRequireDefault(require("dotenv"));
4
4
  var _constants = require("../../common/constants");
5
5
  var _backend = require("./helpers/backend");
6
- var _commands = require("./commands");
7
- var _helpers = require("./helpers");
6
+ var _intunedJson = require("../../common/intunedJson");
8
7
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
9
10
  require("../../common/binStartupScript");
10
11
  _dotenv.default.config({
11
12
  path: `.env`
@@ -15,9 +16,21 @@ process.env.RUN_ENVIRONMENT = "AUTHORING";
15
16
  if (!process.env.FUNCTIONS_DOMAIN) {
16
17
  process.env.FUNCTIONS_DOMAIN = (0, _backend.getBaseUrl)().replace(/\/$/, "");
17
18
  }
18
- _commands.program.configureHelp({
19
- sortSubcommands: true
20
- });
21
- void (0, _helpers.withCLIContext)(async () => {
22
- _commands.program.parse(process.argv);
23
- });
19
+ void (async () => {
20
+ const intunedJson = await (0, _intunedJson.loadIntunedJson)();
21
+ if (intunedJson.isOk() && intunedJson.value.workspaceId) {
22
+ process.env[_constants.WORKSPACE_ID_ENV_VAR_KEY] = intunedJson.value.workspaceId;
23
+ }
24
+ const {
25
+ program
26
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require("./commands")));
27
+ const {
28
+ withCLIContext
29
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require("./helpers/context")));
30
+ await withCLIContext(async () => {
31
+ program.configureHelp({
32
+ sortSubcommands: true
33
+ });
34
+ program.parse(process.argv);
35
+ });
36
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intuned/runtime-dev",
3
- "version": "1.3.17-import.0",
3
+ "version": "1.3.17-ws.0",
4
4
  "description": "Intuned runtime",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
Binary file