arcadible 0.1.48 → 0.1.50

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/bin/arc-init.js CHANGED
@@ -149,7 +149,7 @@ const main = function (argv) {
149
149
  default: conf.template,
150
150
  describe: [
151
151
  "Project template",
152
- "Public GitHub repository (format: user/repo).",
152
+ "Public GitHub repository, or a folder in one (user/repo[/folder]).",
153
153
  ].join("\n"),
154
154
  type: "string",
155
155
  })
package/package.json CHANGED
@@ -79,5 +79,5 @@
79
79
  "scripts": {
80
80
  "test": "node --test \"test/**/*.test.js\""
81
81
  },
82
- "version": "0.1.48"
82
+ "version": "0.1.50"
83
83
  }
@@ -22,6 +22,7 @@ const ArcError = error.ArcError;
22
22
  const detectVersion = manifest.detectVersion;
23
23
  const join = path.join;
24
24
  const prepare = manifest.prepare;
25
+ const readdir = fs.readdir;
25
26
  const remove = fs.remove;
26
27
  const resolve = path.resolve;
27
28
 
@@ -37,6 +38,28 @@ const removeLicense = function (dest) {
37
38
 
38
39
  // [function]
39
40
 
41
+ const unavailable = function (src, cause) {
42
+ return new ArcError(
43
+ cfgcode.TEMPLATE_UNAVAILABLE,
44
+ phrase.templateUnavailable(src),
45
+ { cause },
46
+ );
47
+ };
48
+
49
+ // [function]
50
+
51
+ // degit copies nothing, without failing, from a folder a repository doesn't
52
+ // have, so an empty project fails as a missing repository does.
53
+ const ensureCopied = async function (src, dest) {
54
+ const names = await readdir(dest).catch(() => []);
55
+ if (names.length === 0) {
56
+ await remove(dest);
57
+ throw unavailable(src);
58
+ }
59
+ };
60
+
61
+ // [function]
62
+
40
63
  const scaffold = function (src, dest, { onInitBegin }) {
41
64
  if (onInitBegin) {
42
65
  onInitBegin({ dest, src });
@@ -44,14 +67,9 @@ const scaffold = function (src, dest, { onInitBegin }) {
44
67
  return degit(src, { cache: false, force: true, verbose: false })
45
68
  .clone(dest)
46
69
  .catch((ex) => {
47
- throw new ArcError(
48
- cfgcode.TEMPLATE_UNAVAILABLE,
49
- phrase.templateUnavailable(src),
50
- {
51
- cause: ex,
52
- },
53
- );
54
- });
70
+ throw unavailable(src, ex);
71
+ })
72
+ .then(() => ensureCopied(src, dest));
55
73
  };
56
74
 
57
75
  // [function]
@@ -8,7 +8,7 @@ const phrase = require("../phrase");
8
8
  // [declare]
9
9
 
10
10
  const HANDLE = cfgproduct.handle;
11
- const STARTER = `${HANDLE}/starter`;
11
+ const STARTERS = `${HANDLE}/starters`;
12
12
 
13
13
  // [export]
14
14
 
@@ -17,29 +17,29 @@ module.exports = {
17
17
  {
18
18
  description: phrase.starterBlank(),
19
19
  name: "Blank",
20
- value: STARTER,
20
+ value: `${STARTERS}/blank`,
21
21
  },
22
22
  {
23
23
  description: phrase.starterThreeJs(),
24
24
  name: "Three.js",
25
- value: `${STARTER}-threejs`,
25
+ value: `${STARTERS}/threejs`,
26
26
  },
27
27
  {
28
28
  description: phrase.starterPhaser(),
29
29
  name: "Phaser",
30
- value: `${STARTER}-phaser`,
30
+ value: `${STARTERS}/phaser`,
31
31
  },
32
32
  {
33
33
  description: phrase.starterPixiJs(),
34
34
  name: "PixiJS",
35
- value: `${STARTER}-pixijs`,
35
+ value: `${STARTERS}/pixijs`,
36
36
  },
37
37
  {
38
38
  description: phrase.starterBabylonJs(),
39
39
  name: "Babylon.js",
40
- value: `${STARTER}-babylonjs`,
40
+ value: `${STARTERS}/babylonjs`,
41
41
  },
42
42
  ],
43
- default: STARTER,
43
+ default: `${STARTERS}/blank`,
44
44
  message: "Template",
45
45
  };
package/src/phrase.js CHANGED
@@ -823,7 +823,7 @@ const tagPushed = function (tag) {
823
823
  const templateUnavailable = function (template) {
824
824
  return blocks(
825
825
  `Unable to download template ${template}.`,
826
- "Check that it's a public GitHub repository.",
826
+ "Check that it's a public GitHub repository, or a folder in one.",
827
827
  );
828
828
  };
829
829
 
package/src/serve/game.js CHANGED
@@ -182,4 +182,4 @@ const gameHandler = function ({ files, onRemote = () => null, page, remote }) {
182
182
 
183
183
  // [export]
184
184
 
185
- module.exports = { endWith, gameHandler, segmentsOf };
185
+ module.exports = { endWith, gameHandler };
@@ -60,4 +60,4 @@ const watchDir = function (dir, onChange) {
60
60
 
61
61
  // [export]
62
62
 
63
- module.exports = { SETTLE, reloader, watchDir };
63
+ module.exports = { reloader, watchDir };