-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathcreate-package.sh
executable file
·56 lines (49 loc) · 1.51 KB
/
create-package.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# Creates a package with the given name.
# The name is the directory it will be housed in.
# The name will implicitly have the @endo org prefix.
#
# Usage: scripts/create-package.sh NAME
# Example: scripts/create-package.sh console
set -ueo pipefail
DIR=$(dirname -- "${BASH_SOURCE[0]}")
cd "$DIR/.."
NAME=$1
PKGJSON=packages/$NAME/package.json
mkdir -p "packages/$NAME/"{src,dist,test}
(cd packages/skel; find . -print0 | xargs -0 tar c) |
(cd "packages/$NAME"; tar x)
NEWPKGJSONHASH=$(
jq --arg name "$NAME" '{
name: null,
version: null,
private: null,
description: null,
keywords: [],
author: "Endo contributors",
license: "Apache-2.0",
homepage: null,
repository: null,
bugs: null,
type: null,
main: null,
module: null,
exports: {},
scripts: {},
dependencies: {},
devDependencies: {},
files: [],
publishConfig: null,
eslintConfig: null,
ava: null,
} + . + {
name: "@endo/\($name)",
version: "0.1.0",
homepage: (.homepage // "https://github.com/endojs/endo/tree/master/packages/\($name)#readme"),
repository: (.repository + { directory: "packages/\($name)" }),
scripts: ((.scripts // {}) | to_entries | sort_by(.key) | from_entries),
dependencies: ((.dependencies // {}) | to_entries | sort_by(.key) | from_entries),
devDependencies: ((.devDependencies // {}) | to_entries | sort_by(.key) | from_entries),
}' "$PKGJSON" | git hash-object -w --stdin
)
git cat-file blob "$NEWPKGJSONHASH" > "$PKGJSON"