@coloop-ai/create-package 0.1.0 → 0.1.1

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.
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execSync } from 'node:child_process'
4
+
5
+ const TEMPLATE_REPO = 'Genei-Ltd/ts-package-template'
6
+ const GITHUB_ORG = 'Genei-Ltd'
7
+
8
+ function run(cmd, opts = {}) {
9
+ execSync(cmd, { stdio: 'inherit', ...opts })
10
+ }
11
+
12
+ function check(cmd) {
13
+ try {
14
+ execSync(cmd, { stdio: 'ignore' })
15
+ return true
16
+ } catch {
17
+ return false
18
+ }
19
+ }
20
+
21
+ // ── Parse arguments ──────────────────────────────────────────────
22
+
23
+ const [name, description = 'A TypeScript package published to @coloop-ai'] =
24
+ process.argv.slice(2)
25
+
26
+ if (!name) {
27
+ console.log('Usage: bun create @coloop-ai/package <name> ["description"]')
28
+ console.log('')
29
+ console.log(
30
+ 'Example: bun create @coloop-ai/package my-cool-lib "A really cool library"',
31
+ )
32
+ process.exit(1)
33
+ }
34
+
35
+ // ── Preflight checks ─────────────────────────────────────────────
36
+
37
+ for (const cmd of ['gh', 'git', 'bun']) {
38
+ if (!check(`command -v ${cmd}`)) {
39
+ console.error(`Error: '${cmd}' is required but not installed.`)
40
+ process.exit(1)
41
+ }
42
+ }
43
+
44
+ if (!check('gh auth status')) {
45
+ console.error(
46
+ "Error: GitHub CLI is not authenticated. Run 'gh auth login' first.",
47
+ )
48
+ process.exit(1)
49
+ }
50
+
51
+ // ── Create repo from template ────────────────────────────────────
52
+
53
+ console.log(`Creating ${GITHUB_ORG}/${name} from template...`)
54
+ run(
55
+ `gh repo create ${GITHUB_ORG}/${name} --template ${TEMPLATE_REPO} --clone --public`,
56
+ )
57
+
58
+ // ── Run init.sh ──────────────────────────────────────────────────
59
+
60
+ run(`./init.sh ${name} "${description}"`, { cwd: name })
61
+
62
+ // ── Push ─────────────────────────────────────────────────────────
63
+
64
+ console.log('Pushing to origin...')
65
+ run('git push -u origin main --force', { cwd: name })
66
+
67
+ console.log('')
68
+ console.log(`Your package @coloop-ai/${name} is live at:`)
69
+ console.log(` https://github.com/${GITHUB_ORG}/${name}`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coloop-ai/create-package",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Scaffold a new @coloop-ai TypeScript package from the template.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -11,7 +11,7 @@
11
11
  "url": "https://github.com/Genei-Ltd/create-package/issues"
12
12
  },
13
13
  "homepage": "https://github.com/Genei-Ltd/create-package#readme",
14
- "bin": "./bin/create-package",
14
+ "bin": "./bin/create-package.mjs",
15
15
  "files": [
16
16
  "bin"
17
17
  ],
@@ -1,70 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- # ── @coloop-ai/create-package ────────────────────────────────────
5
- # Scaffolds a new @coloop-ai TypeScript package from the template.
6
- #
7
- # Usage:
8
- # bun create @coloop-ai/package <name> ["description"]
9
- # npx @coloop-ai/create-package <name> ["description"]
10
- #
11
- # Example:
12
- # bun create @coloop-ai/package my-cool-lib "A really cool library"
13
- # ──────────────────────────────────────────────────────────────────
14
-
15
- TEMPLATE_REPO="Genei-Ltd/ts-package-template"
16
- GITHUB_ORG="Genei-Ltd"
17
-
18
- # ── Parse arguments ───────────────────────────────────────────────
19
-
20
- if [ $# -lt 1 ]; then
21
- echo "Usage: bun create @coloop-ai/package <name> [\"description\"]"
22
- echo ""
23
- echo "Example: bun create @coloop-ai/package my-cool-lib \"A really cool library\""
24
- exit 1
25
- fi
26
-
27
- PACKAGE_NAME="$1"
28
- DESCRIPTION="${2:-A TypeScript package published to @coloop-ai}"
29
-
30
- # ── Preflight checks ─────────────────────────────────────────────
31
-
32
- for cmd in gh git bun; do
33
- if ! command -v "$cmd" &> /dev/null; then
34
- echo "Error: '${cmd}' is required but not installed."
35
- exit 1
36
- fi
37
- done
38
-
39
- if ! gh auth status &> /dev/null; then
40
- echo "Error: GitHub CLI is not authenticated. Run 'gh auth login' first."
41
- exit 1
42
- fi
43
-
44
- if [ -d "$PACKAGE_NAME" ]; then
45
- echo "Error: Directory '${PACKAGE_NAME}' already exists."
46
- exit 1
47
- fi
48
-
49
- # ── Create repo from template ────────────────────────────────────
50
-
51
- echo "Creating ${GITHUB_ORG}/${PACKAGE_NAME} from template..."
52
- gh repo create "${GITHUB_ORG}/${PACKAGE_NAME}" \
53
- --template "$TEMPLATE_REPO" \
54
- --clone \
55
- --public
56
-
57
- cd "$PACKAGE_NAME"
58
-
59
- # ── Run init.sh ──────────────────────────────────────────────────
60
-
61
- ./init.sh "$PACKAGE_NAME" "$DESCRIPTION"
62
-
63
- # ── Push ──────────────────────────────────────────────────────────
64
-
65
- echo "Pushing to origin..."
66
- git push -u origin main --force
67
-
68
- echo ""
69
- echo "Your package @coloop-ai/${PACKAGE_NAME} is live at:"
70
- echo " https://github.com/${GITHUB_ORG}/${PACKAGE_NAME}"