@ts-max/deploy 0.0.17 → 0.0.18

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.
Files changed (2) hide show
  1. package/dist/index.cjs +13 -31
  2. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -10,26 +10,8 @@ const axios = require("axios");
10
10
  const os = require("os");
11
11
  const chalk = require("chalk");
12
12
  const inquirer = require("inquirer");
13
- function _interopNamespaceDefault(e) {
14
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
15
- if (e) {
16
- for (const k in e) {
17
- if (k !== "default") {
18
- const d = Object.getOwnPropertyDescriptor(e, k);
19
- Object.defineProperty(n, k, d.get ? d : {
20
- enumerable: true,
21
- get: () => e[k]
22
- });
23
- }
24
- }
25
- }
26
- n.default = e;
27
- return Object.freeze(n);
28
- }
29
- const path__namespace = /* @__PURE__ */ _interopNamespaceDefault(path);
30
- const process__namespace = /* @__PURE__ */ _interopNamespaceDefault(process);
31
- const __cwd = process__namespace.cwd();
32
- const pak = require(path__namespace.join(__cwd, "package.json"));
13
+ const __cwd = process.cwd();
14
+ const pak = require(path.join(__cwd, "package.json"));
33
15
  const account = getAccount();
34
16
  const defaultConfig = {
35
17
  CONFIG_FILE: "deploy/config.js",
@@ -39,7 +21,7 @@ const defaultConfig = {
39
21
  APP_TITLE: pak.title || pak.name,
40
22
  JENKINS_BASE_URL: "",
41
23
  JENKINS_JOB_NAME: pak.name?.replace(/\s+/, "-").toLowerCase(),
42
- JENKINS_JOB_XML_FILE: path__namespace.join(__dirname, "job.xml"),
24
+ JENKINS_JOB_XML_FILE: path.join(__dirname, "job.xml"),
43
25
  RANCHER: false,
44
26
  RANCHER_URL: void 0,
45
27
  RANCHER_BEARER_TOKEN: void 0,
@@ -60,7 +42,7 @@ const config = Object.keys(defaultConfig).reduce((prev, curr) => {
60
42
  }, {});
61
43
  function getConfig() {
62
44
  const CONFIG_FILE = getProcessEnv("CONFIG_FILE") || defaultConfig.CONFIG_FILE;
63
- let configPath = path__namespace.resolve(__cwd, CONFIG_FILE);
45
+ let configPath = path.resolve(__cwd, CONFIG_FILE);
64
46
  return fs.existsSync(configPath) ? require(configPath) : {};
65
47
  }
66
48
  function val(key) {
@@ -72,8 +54,8 @@ function val(key) {
72
54
  return _defaultValue;
73
55
  }
74
56
  function getProcessEnv(key) {
75
- if (key in process__namespace.env) {
76
- const value = process__namespace.env[key];
57
+ if (key in process.env) {
58
+ const value = process.env[key];
77
59
  if (value === "false") return false;
78
60
  if (value === "true") return true;
79
61
  return value;
@@ -87,11 +69,11 @@ function getAccount() {
87
69
  function getGitRoot() {
88
70
  let rootPath = __cwd;
89
71
  while (rootPath) {
90
- if (fs.existsSync(path__namespace.join(rootPath, ".git"))) {
72
+ if (fs.existsSync(path.join(rootPath, ".git"))) {
91
73
  break;
92
74
  }
93
- const paths = rootPath.split(path__namespace.sep);
94
- rootPath = paths.slice(0, paths.length - 1).join(path__namespace.sep);
75
+ const paths = rootPath.split(path.sep);
76
+ rootPath = paths.slice(0, paths.length - 1).join(path.sep);
95
77
  }
96
78
  if (rootPath) return rootPath;
97
79
  throw new Error("非git仓库,或 非仓库中子文件夹");
@@ -106,7 +88,7 @@ function httpToSSH(url) {
106
88
  }
107
89
  function getGitUrl() {
108
90
  const gitRoot = getGitRoot();
109
- const gitConfigPath = path__namespace.join(gitRoot, ".git", "config");
91
+ const gitConfigPath = path.join(gitRoot, ".git", "config");
110
92
  const configContent = fs.readFileSync(gitConfigPath, "UTF-8");
111
93
  const arr = configContent.split("\n ");
112
94
  const url = arr.find((item) => item.startsWith("url = ")) || "";
@@ -174,7 +156,7 @@ async function showJenkinsLog(buildNumber) {
174
156
  return new Promise((resolve, reject) => {
175
157
  const log = getJenkinsLogStream(buildNumber);
176
158
  log.on("data", function(text) {
177
- process__namespace.stdout.write(text);
159
+ process.stdout.write(text);
178
160
  });
179
161
  log.on("error", function(err) {
180
162
  reject(err);
@@ -192,10 +174,10 @@ async function showJenkinsLog(buildNumber) {
192
174
  async function getJenkinsConfigXml() {
193
175
  const gitUrl = config.GIT_URL;
194
176
  const branch = config.GIT_BRANCH;
195
- const shell = fs.readFileSync(path.resolve(process__namespace.cwd(), config.SHELL_FILE), "UTF-8");
177
+ const shell = fs.readFileSync(path.resolve(process.cwd(), config.SHELL_FILE), "UTF-8");
196
178
  const nodeVersion = config.NODE_VERSION;
197
179
  if (!gitUrl) throw Error("git 地址不能为空!");
198
- let xmlTemplate = fs.readFileSync(path.resolve(process__namespace.cwd(), config.JENKINS_JOB_XML_FILE), "UTF-8") || "";
180
+ let xmlTemplate = fs.readFileSync(path.resolve(process.cwd(), config.JENKINS_JOB_XML_FILE), "UTF-8") || "";
199
181
  const parser = new xml2js.Parser(
200
182
  /* options */
201
183
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-max/deploy",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "部署脚本",
5
5
  "main": "./dist/index.cjs",
6
6
  "types": "./dist/index.d.ts",
@@ -45,5 +45,5 @@
45
45
  "cli"
46
46
  ],
47
47
  "license": "MIT",
48
- "gitHead": "ca0ce611c189598e39dfe8a71bdce8f714a28ea8"
48
+ "gitHead": "d1f2cf24a6fe65d2a2e1c6fa8d5fcc945b732279"
49
49
  }