badmfck-api-server 4.1.45 → 4.1.46

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.
@@ -67,6 +67,7 @@ async function Deploy(opt) {
67
67
  var execResult = run("npm run build");
68
68
  console.log(execResult);
69
69
  const items = [];
70
+ let spaMode = false;
70
71
  const binExists = fs_1.default.existsSync("./bin");
71
72
  if (binExists) {
72
73
  items.push("./bin");
@@ -78,8 +79,8 @@ async function Deploy(opt) {
78
79
  }
79
80
  }
80
81
  else if (fs_1.default.existsSync("./dist") && fs_1.default.existsSync(path_1.default.resolve("dist", "index.html"))) {
81
- console.log("No ./bin found — detected ./dist with index.html, using it as distribution");
82
- items.push("./dist");
82
+ spaMode = true;
83
+ console.log("No ./bin found — using entire ./dist contents as distribution");
83
84
  }
84
85
  if (Array.isArray(opt.includes)) {
85
86
  for (const inc of opt.includes) {
@@ -95,8 +96,8 @@ async function Deploy(opt) {
95
96
  items.push(inc);
96
97
  }
97
98
  }
98
- if (items.length === 0) {
99
- throw new Error("Nothing to archive (no ./bin and no includes specified)");
99
+ if (items.length === 0 && !spaMode) {
100
+ throw new Error("Nothing to archive (no ./bin, no ./dist/index.html, no valid includes)");
100
101
  }
101
102
  const excludes = new Set();
102
103
  const addExclude = (raw, source) => {
@@ -122,11 +123,28 @@ async function Deploy(opt) {
122
123
  addExclude(ex, "config.excludes");
123
124
  }
124
125
  const excludeArgs = Array.from(excludes).map(p => `--exclude=${p}`);
125
- console.log("Archiving:", items.join(", "));
126
+ const tarArgs = ["-czvf", archiveName, ...excludeArgs];
127
+ if (spaMode) {
128
+ tarArgs.push("-C", "./dist", ".");
129
+ if (items.length > 0) {
130
+ tarArgs.push("-C", process.cwd(), ...items);
131
+ }
132
+ }
133
+ else {
134
+ tarArgs.push(...items);
135
+ }
136
+ if (spaMode) {
137
+ console.log("Archiving: contents of ./dist (recursively, at archive root)");
138
+ if (items.length > 0)
139
+ console.log("Also archiving from cwd:", items.join(", "));
140
+ }
141
+ else {
142
+ console.log("Archiving:", items.join(", "));
143
+ }
126
144
  if (excludeArgs.length > 0)
127
145
  console.log("Excluding:", Array.from(excludes).join(", "));
128
146
  try {
129
- (0, child_process_1.execFileSync)("tar", ["-czvf", archiveName, ...excludeArgs, ...items], { encoding: "utf-8", stdio: "inherit" });
147
+ (0, child_process_1.execFileSync)("tar", tarArgs, { encoding: "utf-8", stdio: "inherit" });
130
148
  }
131
149
  catch (err) {
132
150
  console.error(`\ntar failed while creating ${archiveName}\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "4.1.45",
3
+ "version": "4.1.46",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",