create-acmekit-app 2.13.37 → 2.13.38

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.13.38
4
+
5
+ ### Patch Changes
6
+
7
+ - changes
8
+
9
+ - Updated dependencies []:
10
+ - @acmekit/telemetry@2.13.38
11
+ - @acmekit/deps@2.13.38
12
+
3
13
  ## 2.13.37
4
14
 
5
15
  ### Patch Changes
package/README.md CHANGED
@@ -54,5 +54,5 @@ Then, answer the prompted questions to setup your PostgreSQL database and AcmeKi
54
54
 
55
55
  | Option | Description | Default value |
56
56
  |--------------------|-------------------------------------------------------|------------------------------------------------------|
57
- | `--repo-url <url>` | Create AcmeKit project from a different repository URL | `https://github.com/acmekit/acmekit-starter-default` |
57
+ | `--repo-url <url>` | Create AcmeKit project from a different repository URL | Default template from [acmekit/acmekit](https://github.com/acmekit/acmekit) |
58
58
  | `--seed` | Using this option seeds the database with demo data | false |
@@ -4,19 +4,40 @@ import { isAbortError } from "./create-abort-controller.js";
4
4
  import execute from "./execute.js";
5
5
  import logMessage from "./log-message.js";
6
6
  import { execFileSync } from "child_process";
7
- const DEFAULT_REPO = "https://github.com/acmekit/acmekit-starter-default";
8
- const DEFAULT_PLUGIN_REPO = "https://github.com/acmekit/acmekit-starter-plugin";
7
+ const REPO_URL = "https://github.com/acmekit/acmekit";
9
8
  const BRANCH = "main";
10
- const PLUGIN_BRANCH = "main";
9
+ const DEFAULT_TEMPLATE = "templates/default";
10
+ const PLUGIN_TEMPLATE = "templates/plugin";
11
11
  export default async function cloneRepo({ directoryName = "", repoUrl, abortController, verbose = false, isPlugin = false, }) {
12
- const defaultRepo = isPlugin ? DEFAULT_PLUGIN_REPO : DEFAULT_REPO;
13
- const branch = isPlugin ? PLUGIN_BRANCH : BRANCH;
14
- await execute([
15
- `git clone ${repoUrl || defaultRepo} -b ${branch} ${directoryName} --depth 1`,
16
- {
17
- signal: abortController?.signal,
18
- },
19
- ], { verbose });
12
+ if (repoUrl) {
13
+ await execute([
14
+ `git clone ${repoUrl} -b ${BRANCH} ${directoryName} --depth 1`,
15
+ { signal: abortController?.signal },
16
+ ], { verbose });
17
+ return;
18
+ }
19
+ const templatePath = isPlugin ? PLUGIN_TEMPLATE : DEFAULT_TEMPLATE;
20
+ const tmpDir = `${directoryName}-tmp-${Date.now()}`;
21
+ try {
22
+ await execute([
23
+ `git clone --no-checkout --depth 1 --filter=blob:none --sparse -b ${BRANCH} ${REPO_URL} ${tmpDir}`,
24
+ { signal: abortController?.signal },
25
+ ], { verbose });
26
+ await execute([
27
+ `git -C ${tmpDir} sparse-checkout set ${templatePath}`,
28
+ { signal: abortController?.signal },
29
+ ], { verbose });
30
+ await execute([
31
+ `git -C ${tmpDir} checkout`,
32
+ { signal: abortController?.signal },
33
+ ], { verbose });
34
+ fs.renameSync(path.join(tmpDir, templatePath), directoryName);
35
+ }
36
+ finally {
37
+ if (fs.existsSync(tmpDir)) {
38
+ fs.rmSync(tmpDir, { recursive: true, force: true });
39
+ }
40
+ }
20
41
  }
21
42
  export async function runCloneRepo({ projectName, repoUrl, abortController, spinner, verbose = false, isPlugin = false, }) {
22
43
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-acmekit-app",
3
- "version": "2.13.37",
3
+ "version": "2.13.38",
4
4
  "description": "Create a AcmeKit project using a single command.",
5
5
  "type": "module",
6
6
  "exports": "./dist/index.js",
@@ -14,8 +14,8 @@
14
14
  "test": "../../../node_modules/.bin/jest --passWithNoTests src"
15
15
  },
16
16
  "dependencies": {
17
- "@acmekit/deps": "2.13.37",
18
- "@acmekit/telemetry": "2.13.37",
17
+ "@acmekit/deps": "2.13.38",
18
+ "@acmekit/telemetry": "2.13.38",
19
19
  "boxen": "^5.0.1",
20
20
  "chalk": "^4.1.2",
21
21
  "commander": "^11.0.0",
@@ -14,10 +14,10 @@ type CloneRepoOptions = {
14
14
  isPlugin?: boolean
15
15
  }
16
16
 
17
- const DEFAULT_REPO = "https://github.com/acmekit/acmekit-starter-default"
18
- const DEFAULT_PLUGIN_REPO = "https://github.com/acmekit/acmekit-starter-plugin"
17
+ const REPO_URL = "https://github.com/acmekit/acmekit"
19
18
  const BRANCH = "main"
20
- const PLUGIN_BRANCH = "main"
19
+ const DEFAULT_TEMPLATE = "templates/default"
20
+ const PLUGIN_TEMPLATE = "templates/plugin"
21
21
 
22
22
  export default async function cloneRepo({
23
23
  directoryName = "",
@@ -26,20 +26,51 @@ export default async function cloneRepo({
26
26
  verbose = false,
27
27
  isPlugin = false,
28
28
  }: CloneRepoOptions) {
29
- const defaultRepo = isPlugin ? DEFAULT_PLUGIN_REPO : DEFAULT_REPO
30
- const branch = isPlugin ? PLUGIN_BRANCH : BRANCH
29
+ if (repoUrl) {
30
+ await execute(
31
+ [
32
+ `git clone ${repoUrl} -b ${BRANCH} ${directoryName} --depth 1`,
33
+ { signal: abortController?.signal },
34
+ ],
35
+ { verbose }
36
+ )
37
+ return
38
+ }
39
+
40
+ const templatePath = isPlugin ? PLUGIN_TEMPLATE : DEFAULT_TEMPLATE
41
+ const tmpDir = `${directoryName}-tmp-${Date.now()}`
42
+
43
+ try {
44
+ await execute(
45
+ [
46
+ `git clone --no-checkout --depth 1 --filter=blob:none --sparse -b ${BRANCH} ${REPO_URL} ${tmpDir}`,
47
+ { signal: abortController?.signal },
48
+ ],
49
+ { verbose }
50
+ )
31
51
 
32
- await execute(
33
- [
34
- `git clone ${
35
- repoUrl || defaultRepo
36
- } -b ${branch} ${directoryName} --depth 1`,
37
- {
38
- signal: abortController?.signal,
39
- },
40
- ],
41
- { verbose }
42
- )
52
+ await execute(
53
+ [
54
+ `git -C ${tmpDir} sparse-checkout set ${templatePath}`,
55
+ { signal: abortController?.signal },
56
+ ],
57
+ { verbose }
58
+ )
59
+
60
+ await execute(
61
+ [
62
+ `git -C ${tmpDir} checkout`,
63
+ { signal: abortController?.signal },
64
+ ],
65
+ { verbose }
66
+ )
67
+
68
+ fs.renameSync(path.join(tmpDir, templatePath), directoryName)
69
+ } finally {
70
+ if (fs.existsSync(tmpDir)) {
71
+ fs.rmSync(tmpDir, { recursive: true, force: true })
72
+ }
73
+ }
43
74
  }
44
75
 
45
76
  export async function runCloneRepo({