@mservices-tech/scripts 3.2.2
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 +153 -0
- package/LICENSE +7 -0
- package/README.md +56 -0
- package/add_sandbox_upstream/add_sandbox_upstream.sh +32 -0
- package/buildUsingEsbuild/buildUsingEsbuild.js +54 -0
- package/bump_version/.versionrc.js +20 -0
- package/bump_version/bump_version.sh +93 -0
- package/clean/clean.sh +61 -0
- package/copy_package_build_to_project/copy_package_build_to_project.sh +46 -0
- package/delete_and_fetch_git_tags/delete_and_fetch_git_tags.sh +35 -0
- package/docker/docker.sh +68 -0
- package/docker/docker_utils.sh +143 -0
- package/download_design_system_package/download_design_system_package.sh +41 -0
- package/enrich_changelog_with_dependency_changes/enrich_changelog_with_dependency_changes.sh +289 -0
- package/find_all_javascript_files/find_all_javascript_files.sh +76 -0
- package/find_and_parse_environmental_variable_files/find_and_parse_environmental_variable_files.sh +180 -0
- package/find_references/find_references.sh +50 -0
- package/generateIndexFilesFromTemplate/generateIndexFilesFromTemplate.js +419 -0
- package/get_package_info/get_package_info.sh +103 -0
- package/git_user_stats/git_user_stats.sh +95 -0
- package/index.js +1 -0
- package/is_branch_rebased/is_branch_rebased.sh +44 -0
- package/last_release_commits/last_release_commits.sh +101 -0
- package/list_all_installed_dependencies/list_all_installed_dependencies.sh +40 -0
- package/package.json +14 -0
- package/prepare_obligatory_package_files/prepare_obligatory_package_files.sh +61 -0
- package/publish/publish.sh +89 -0
- package/removeGitHashesFromMarkdownFile/removeGitHashesFromMarkdownFile.js +50 -0
- package/remove_all_node_modules/remove_all_node_modules.sh +26 -0
- package/remove_all_scripts_in_single_workspace/remove_all_scripts_in_single_workspace.sh +62 -0
- package/reverse_proxy/README.md +102 -0
- package/reverse_proxy/clean.sh +8 -0
- package/reverse_proxy/configuration.sh +5 -0
- package/reverse_proxy/generate_certificates.sh +140 -0
- package/reverse_proxy/localhost.ext.template +12 -0
- package/reverse_proxy/nginx_domain_ssl_reverse_proxy.conf.template +89 -0
- package/reverse_proxy/openssl.conf +21 -0
- package/reverse_proxy/reverse_proxy.sh +48 -0
- package/runShellScript/runShellScript.js +49 -0
- package/source_environment_variables/source_environment_variables.sh +38 -0
- package/sync_sandbox_with_upstream/sync_sandbox_with_upstream.sh +53 -0
- package/testIncorrectValues/testIncorrectValues.js +51 -0
- package/typescript_usage_statistics/typescript_usage_statistics.sh +35 -0
- package/utils.sh +337 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# $0 cannot be used when sourcing in the main shell
|
|
4
|
+
source "$(dirname "${BASH_SOURCE[0]}")/../utils.sh"
|
|
5
|
+
|
|
6
|
+
function usage() {
|
|
7
|
+
cat << END
|
|
8
|
+
Usage:
|
|
9
|
+
${BASH_SOURCE[0]} [--help] <--path> [--print]
|
|
10
|
+
Where:
|
|
11
|
+
help - show usage information and exit
|
|
12
|
+
path - path to Yarn workspace with the package
|
|
13
|
+
print - print the output as executable variable
|
|
14
|
+
setting script (useful in subshell execution contexts)
|
|
15
|
+
release_type - release | prerelease; based on that package next version is
|
|
16
|
+
generated (with an rc-{version} suffix or without it)
|
|
17
|
+
|
|
18
|
+
Description:
|
|
19
|
+
Sets the following environment variables with information
|
|
20
|
+
from a given workspace path:
|
|
21
|
+
- PACKAGE_NAME (name of the package, without namespace, after publishing the package)
|
|
22
|
+
- DEVELOPMENT_PACKAGE_NAME (PACKAGE_NAME name with the -development suffix)
|
|
23
|
+
- PACKAGE_SCOPE
|
|
24
|
+
- PACKAGE_VERSION
|
|
25
|
+
- PACKAGE_NEXT_VERSION (the semantic version of the next release)
|
|
26
|
+
These variables are filled with information from the
|
|
27
|
+
respective package.json file read at path given in '--path'.
|
|
28
|
+
END
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function get_package_next_version() {
|
|
32
|
+
local -r package_name="$1"
|
|
33
|
+
local -r release_type="$2"
|
|
34
|
+
|
|
35
|
+
pushd "packages/$package_name" &> /dev/null
|
|
36
|
+
|
|
37
|
+
local next_version_output
|
|
38
|
+
|
|
39
|
+
if [[ $release_type == "prerelease" ]]; then
|
|
40
|
+
local -r current_branch_name=$(git rev-parse --abbrev-ref HEAD | sed -E -e 's/[^a-zA-Z0-9]+/-/g' -e 's/^-//' -e 's/-$//' -e 's/\./-/g')
|
|
41
|
+
|
|
42
|
+
next_version_output=$(
|
|
43
|
+
yarn dlx standard-version@9.5.0 \
|
|
44
|
+
--dry-run \
|
|
45
|
+
--prerelease "$current_branch_name-rc" \
|
|
46
|
+
--tag-prefix="$package_name-"
|
|
47
|
+
)
|
|
48
|
+
else
|
|
49
|
+
next_version_output=$(
|
|
50
|
+
yarn dlx standard-version@9.5.0 \
|
|
51
|
+
--dry-run \
|
|
52
|
+
--tag-prefix="$package_name-"
|
|
53
|
+
)
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
popd &> /dev/null
|
|
57
|
+
# Cut version string after first number, i.e.
|
|
58
|
+
# package-name-1.2.3 → 1.2.3
|
|
59
|
+
# package-name-0.2.28-rc.2 → 0.2.28-rc.2
|
|
60
|
+
echo "$next_version_output" | grep "tagging release" | sed 's/^[^0-9]*\([0-9].*\)/\1/'
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function main() {
|
|
64
|
+
parse_arguments "$@"
|
|
65
|
+
if [ ${PROCESS_ARGUMENTS['--help']} ]; then
|
|
66
|
+
usage
|
|
67
|
+
# return is used instead of exit to prevent calling
|
|
68
|
+
# shell from exiting in sourced execution context
|
|
69
|
+
return
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
if ! [ ${PROCESS_ARGUMENTS['--path']} ]; then
|
|
73
|
+
printf "No path was provided. Run with '--help' for more information.\n"
|
|
74
|
+
# return is used instead of exit to prevent calling
|
|
75
|
+
# shell from exiting in sourced execution context
|
|
76
|
+
return
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
local -r name=$(jq --raw-output ".name" \
|
|
80
|
+
"${PROCESS_ARGUMENTS['--path']%/}/package.json")
|
|
81
|
+
local -r version=$(jq --raw-output ".version" \
|
|
82
|
+
"${PROCESS_ARGUMENTS['--path']}/package.json")
|
|
83
|
+
|
|
84
|
+
DEVELOPMENT_PACKAGE_NAME="${name#@*/}"
|
|
85
|
+
PACKAGE_NAME="${DEVELOPMENT_PACKAGE_NAME%-development}"
|
|
86
|
+
PACKAGE_SCOPE="${name%/*}"
|
|
87
|
+
PACKAGE_VERSION="${version}"
|
|
88
|
+
PACKAGE_NEXT_VERSION=$(get_package_next_version "$PACKAGE_NAME" ${PROCESS_ARGUMENTS['--release_type']})
|
|
89
|
+
|
|
90
|
+
if [ ${PROCESS_ARGUMENTS['--print']} ]; then
|
|
91
|
+
# the '@A' parameter expansion guarantees the string formatted as variable
|
|
92
|
+
# assignment so that the output can be reevaluated by the parent shell by 'eval'
|
|
93
|
+
# more at: https://www.gnu.org/software/bash/manual/bash.html#Brace-Expansion
|
|
94
|
+
printf "%s\n%s\n%s\n%s\n%s\n" \
|
|
95
|
+
"${DEVELOPMENT_PACKAGE_NAME@A}" \
|
|
96
|
+
"${PACKAGE_NAME@A}" \
|
|
97
|
+
"${PACKAGE_SCOPE@A}" \
|
|
98
|
+
"${PACKAGE_VERSION@A}" \
|
|
99
|
+
"${PACKAGE_NEXT_VERSION@A}"
|
|
100
|
+
fi
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
main "$@"
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# Based on:
|
|
4
|
+
# https://gist.github.com/shitchell/783cc8a892ed1591eca2afeb65e8720a
|
|
5
|
+
|
|
6
|
+
source "$(dirname $0)/../utils.sh" || exit 1
|
|
7
|
+
|
|
8
|
+
usage() {
|
|
9
|
+
cat << END
|
|
10
|
+
Usage:
|
|
11
|
+
${BASH_SOURCE[0]} [--help] <--config> [--options]
|
|
12
|
+
Where:
|
|
13
|
+
help - print usage information and exit
|
|
14
|
+
config - configuration file path
|
|
15
|
+
options - options to pass to 'git log' as quoted string
|
|
16
|
+
Description:
|
|
17
|
+
Shows user stats (commits, files modified, insertions, deletions, and total
|
|
18
|
+
lines modified) for a repository.
|
|
19
|
+
Example configuration:
|
|
20
|
+
--
|
|
21
|
+
# !#/usr/bin/env bash
|
|
22
|
+
|
|
23
|
+
accounts="\
|
|
24
|
+
****@services.com.pl ****@users.noreply.github.com
|
|
25
|
+
****@gmail.com ****@users.noreply.github.com"
|
|
26
|
+
--
|
|
27
|
+
|
|
28
|
+
The 'accounts' variable defines different email groups for actual users.
|
|
29
|
+
You can create a group when a contributor uses multiple git accounts
|
|
30
|
+
or emails to sum up their contributions. Actual users are separated by a
|
|
31
|
+
newline, while their aliases (emails) are separated by spaces.
|
|
32
|
+
END
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function main() {
|
|
36
|
+
parse_arguments "$@"
|
|
37
|
+
if [ ${PROCESS_ARGUMENTS['--help']} ]; then
|
|
38
|
+
usage
|
|
39
|
+
exit 0
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
if [ ${PROCESS_ARGUMENTS['--config']} ]; then
|
|
43
|
+
source ${PROCESS_ARGUMENTS['--config']} || exit 1
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
# this is needed to generate statistics for large repositories
|
|
47
|
+
git config diff.renameLimit 10000
|
|
48
|
+
git log "${PROCESS_ARGUMENTS['--options']}" --format='author: %ae' --numstat \
|
|
49
|
+
| tr '[A-Z]' '[a-z]' \
|
|
50
|
+
| grep -v '^$' \
|
|
51
|
+
| grep -v '^-' \
|
|
52
|
+
| awk -v account_data="$accounts" '
|
|
53
|
+
BEGIN {
|
|
54
|
+
split(account_data, accounts, "\n")
|
|
55
|
+
}
|
|
56
|
+
{
|
|
57
|
+
if ($1 == "author:") {
|
|
58
|
+
author = $2;
|
|
59
|
+
for(account in accounts) {
|
|
60
|
+
split(accounts[account], emails)
|
|
61
|
+
for(email in emails) {
|
|
62
|
+
if(author == emails[email]) {
|
|
63
|
+
author = emails[1]
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
commits[author]++;
|
|
68
|
+
} else {
|
|
69
|
+
insertions[author] += $1;
|
|
70
|
+
deletions[author] += $2;
|
|
71
|
+
total[author] += $1 + $2;
|
|
72
|
+
# if this is the first time seeing this file for this
|
|
73
|
+
# author, increment their file count
|
|
74
|
+
author_file = author ":" $3;
|
|
75
|
+
if (!(author_file in seen)) {
|
|
76
|
+
seen[author_file] = 1;
|
|
77
|
+
files[author]++;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
END {
|
|
82
|
+
printf("email,commits,files,insertions,deletions,lines\n")
|
|
83
|
+
# Print the stats for each user, sorted by total lines
|
|
84
|
+
n = asorti(total, sorted_emails, "@val_num_desc");
|
|
85
|
+
for (i = 1; i <= n; i++) {
|
|
86
|
+
email = sorted_emails[i];
|
|
87
|
+
printf("%s,%s,%s,%s,%s,%s\n",
|
|
88
|
+
email, commits[email], files[email],
|
|
89
|
+
insertions[email], deletions[email], total[email]);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
'
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
main "$@"
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var v=(e,n)=>{for(var r in n)a(e,r,{get:n[r],enumerable:!0})},b=(e,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of f(n))!p.call(e,i)&&i!==r&&a(e,i,{get:()=>n[i],enumerable:!(s=l(n,i))||s.enumerable});return e};var c=e=>b(a({},"__esModule",{value:!0}),e);var y={};v(y,{checkEnvironmentVariables:()=>t,getConfigFromEnvironmentVariables:()=>o});module.exports=c(y);function t(e){let n={};for(let r of e){if(process.env[r]===void 0||!process.env[r])throw new Error(`Missing environment variable: ${r}`);typeof process.env[r]=="string"&&(n[r]=process.env[r])}return n}function o(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`Invalid config: ${e}`);let n=Object.keys(e);for(let r of n)if(typeof r!="string"&&o(e[r]),(process.env[r]===void 0||!process.env[r])&&e[r]===void 0)throw new Error(`Missing environment variable in configuration: ${r}`);return e}0&&(module.exports={checkEnvironmentVariables,getConfigFromEnvironmentVariables});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
source "$(dirname $0)/../utils.sh" || exit 1
|
|
4
|
+
|
|
5
|
+
usage() {
|
|
6
|
+
cat << END
|
|
7
|
+
Usage:
|
|
8
|
+
${BASH_SOURCE[0]} [--help]
|
|
9
|
+
Where:
|
|
10
|
+
help - print usage information and exit
|
|
11
|
+
Description:
|
|
12
|
+
Checks if the current branch is rebased to master.
|
|
13
|
+
If the current branch is not rebased to master, will exit with code 1.
|
|
14
|
+
Otherwise, will exit with code 0.
|
|
15
|
+
END
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function main() {
|
|
19
|
+
parse_arguments "$@"
|
|
20
|
+
if [ ${PROCESS_ARGUMENTS['--help']} ]; then
|
|
21
|
+
usage
|
|
22
|
+
exit 0
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
current_branch=$(git rev-parse --abbrev-ref HEAD)
|
|
26
|
+
|
|
27
|
+
git fetch origin master:master
|
|
28
|
+
|
|
29
|
+
hash_master=$(git show-ref --heads -s origin master)
|
|
30
|
+
hash_current_branch=$(git merge-base origin/master ${current_branch})
|
|
31
|
+
|
|
32
|
+
echo "Current branch hash: ${hash_current_branch}"
|
|
33
|
+
echo "Master branch hash: ${hash_master}"
|
|
34
|
+
|
|
35
|
+
if [ "${hash_master}" = "${hash_current_branch}" ]; then
|
|
36
|
+
printf "Branch ${current_branch} is rebased to master.\n"
|
|
37
|
+
exit 0
|
|
38
|
+
else
|
|
39
|
+
printf "Branch ${current_branch} is not rebased to master.\n"
|
|
40
|
+
exit 1
|
|
41
|
+
fi
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
main "$@"
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
source "$(dirname $0)/../utils.sh" || exit 1
|
|
4
|
+
|
|
5
|
+
function usage() {
|
|
6
|
+
cat << END
|
|
7
|
+
Usage:
|
|
8
|
+
${BASH_SOURCE[0]} [--help] <--package-name=package_name> [--package-directory=directory]
|
|
9
|
+
Where:
|
|
10
|
+
help - print usage information and exit
|
|
11
|
+
package-name - name of the package, for which we want to get the list of
|
|
12
|
+
release commits (it has to be aligned with version tag names,
|
|
13
|
+
for example: if a package version is tagged
|
|
14
|
+
'some-package-name-1.2.3', 'some-package-name' has to be
|
|
15
|
+
passed in the package-name argument)
|
|
16
|
+
package-directory - directory where to look for changelogs commits
|
|
17
|
+
of the given package (optional)
|
|
18
|
+
|
|
19
|
+
Description:
|
|
20
|
+
Returns all commits between two most recent (SemVer) tags
|
|
21
|
+
for a given list of directories.
|
|
22
|
+
|
|
23
|
+
Example:
|
|
24
|
+
./scripts/last_release_commits.sh \
|
|
25
|
+
--package-name="design-system-automator"
|
|
26
|
+
END
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# Returns all commits between two most recent (SemVer) tags
|
|
30
|
+
# without 'chore' commits
|
|
31
|
+
#
|
|
32
|
+
# Usage:
|
|
33
|
+
# get_commits_for_version_tags version_tag_end version_tag_start directory
|
|
34
|
+
function get_commits_for_version_tags() {
|
|
35
|
+
local last_version="$1"
|
|
36
|
+
local version_before_last="$2"
|
|
37
|
+
local package_directory="$3"
|
|
38
|
+
|
|
39
|
+
local version_compare_string="$last_version...$version_before_last"
|
|
40
|
+
|
|
41
|
+
# Initial version, return just commits for that version, from the directory
|
|
42
|
+
# of the package
|
|
43
|
+
if [[ "$last_version" == "$version_before_last" ]]; then
|
|
44
|
+
version_compare_string="$last_version"
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
git log "$version_compare_string" --pretty='format:%s' "$package_directory" \
|
|
48
|
+
| grep --invert-match --extended-regexp 'chore(\(|:)'
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function main() {
|
|
52
|
+
parse_arguments "$@"
|
|
53
|
+
if [ ${PROCESS_ARGUMENTS['--help']} ]; then
|
|
54
|
+
usage
|
|
55
|
+
exit 0
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
if [ -z ${PROCESS_ARGUMENTS['--package-name']} ]; then
|
|
59
|
+
printf "No package name provided. Run with '--help' for more information\n"
|
|
60
|
+
exit 1
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
package_name=${PROCESS_ARGUMENTS['--package-name']}
|
|
64
|
+
|
|
65
|
+
package_directory=${PROCESS_ARGUMENTS['--package-directory']:-"./packages/$package_name"}
|
|
66
|
+
|
|
67
|
+
all_tagged_versions="$(git --no-pager tag --list "$package_name-[0-9]*" \
|
|
68
|
+
| grep --invert-match '\-rc' \
|
|
69
|
+
|
|
|
70
|
+
# filter-out prereleases
|
|
71
|
+
sort --version-sort)"
|
|
72
|
+
version_count=$(echo "$all_tagged_versions" | wc --lines)
|
|
73
|
+
|
|
74
|
+
local -r last_version=$(echo "$all_tagged_versions" | tail -1)
|
|
75
|
+
local -r version_before_last=$(echo "$all_tagged_versions" | tail -2 | head -1)
|
|
76
|
+
|
|
77
|
+
if [[ "$last_version" == "$version_before_last" && "$version_count" > 1 ]]; then
|
|
78
|
+
printf "Found only one version tag (not searching through rc versions). Make sure you have two versions already published\n" 1>&2
|
|
79
|
+
exit 1
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
local combined_git_log_output=""
|
|
83
|
+
|
|
84
|
+
git_log_output_for_package=$(get_commits_for_version_tags \
|
|
85
|
+
"$last_version" "$version_before_last" "$package_directory")
|
|
86
|
+
|
|
87
|
+
combined_git_log_output=$(echo -e "$combined_git_log_output\n$git_log_output_for_package")
|
|
88
|
+
|
|
89
|
+
if [ -z "${combined_git_log_output}" ]; then
|
|
90
|
+
printf "Returning empty list of commits between versions %s and %s\n" \
|
|
91
|
+
"$last_version" \
|
|
92
|
+
"$version_before_last" 1>&2
|
|
93
|
+
|
|
94
|
+
exit 0
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
echo -e "$combined_git_log_output" \
|
|
98
|
+
| sed '/^$/d' # remove empty lines
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
main "$@"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
source "$(dirname $0)/../utils.sh" || exit 1
|
|
4
|
+
|
|
5
|
+
usage() {
|
|
6
|
+
cat << END
|
|
7
|
+
Usage:
|
|
8
|
+
${BASH_SOURCE[0]} [--help]
|
|
9
|
+
Where:
|
|
10
|
+
help - print usage information and exit
|
|
11
|
+
Description:
|
|
12
|
+
Lists all dependencies installed in the monorepo
|
|
13
|
+
as well as in the packages. Run at the root level.
|
|
14
|
+
END
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function list_dependencies() {
|
|
18
|
+
FORCE_COLOR=0 yarn info --recursive --dependents
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function main() {
|
|
22
|
+
parse_arguments "$@"
|
|
23
|
+
if [ ${PROCESS_ARGUMENTS['--help']} ]; then
|
|
24
|
+
usage
|
|
25
|
+
exit 0
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
# Top-level directory node_modules
|
|
29
|
+
list_dependencies
|
|
30
|
+
|
|
31
|
+
# Workspaces (packages/workspace_name)
|
|
32
|
+
for workspace in $(ls -1 packages/); do
|
|
33
|
+
pushd "packages/""$workspace" > /dev/null || exit
|
|
34
|
+
printf "packages/""$workspace"
|
|
35
|
+
list_dependencies
|
|
36
|
+
popd > /dev/null || exit
|
|
37
|
+
done
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
main "$@"
|
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mservices-tech/scripts",
|
|
3
|
+
"version": "3.2.2",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"packageManager": "yarn@4.4.1",
|
|
6
|
+
"bin": {
|
|
7
|
+
"scripts": "runShellScript/runShellScript.js"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"esbuild": "0.24.0",
|
|
11
|
+
"prettier": "3.2.5",
|
|
12
|
+
"standard-version": "9.5.0"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
source "$(dirname $0)/../utils.sh" || exit 1
|
|
4
|
+
|
|
5
|
+
function usage() {
|
|
6
|
+
cat << END
|
|
7
|
+
Usage:
|
|
8
|
+
./prepare_obligatory_package_files.sh [--help]
|
|
9
|
+
Where:
|
|
10
|
+
help - print usage information and exit
|
|
11
|
+
Description:
|
|
12
|
+
Creates obligatory package files in the 'build' directory:
|
|
13
|
+
1. Modifies build/package.json for release by removing fields not needed
|
|
14
|
+
in the release package, and adjusting the public page name.
|
|
15
|
+
2. Copies CHANGELOG.md to that directory
|
|
16
|
+
3. Copies LICENSE to that directory
|
|
17
|
+
(if there is LICENSE provided for that package)
|
|
18
|
+
END
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function modify_package_json_for_release() {
|
|
22
|
+
printf "Modifying build/package.json for release...\n"
|
|
23
|
+
|
|
24
|
+
# yarn resolves the package name into a link to the monorepo - changing the package
|
|
25
|
+
# name is required in order to avoid this problem, and to be able to use the copy
|
|
26
|
+
# from the public npm registry
|
|
27
|
+
jq --raw-output \
|
|
28
|
+
'del( .devDependencies, .eslintConfig, .prettier, .publishConfig, .repository, .scripts ) | .name = (.name | sub("-development$" ; ""))' \
|
|
29
|
+
package.json > build/package.json
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function copy_changelog_to_build() {
|
|
33
|
+
if [ ! -f CHANGELOG.md ]; then
|
|
34
|
+
printf "No CHANGELOG.md found. You need to create a changelog in order to release a package. Exiting\n"
|
|
35
|
+
exit 1
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
cp CHANGELOG.md build/
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function copy_license_to_build() {
|
|
42
|
+
if [ ! -f LICENSE ]; then
|
|
43
|
+
printf "No LICENSE found, moving to the next step\n"
|
|
44
|
+
else
|
|
45
|
+
cp LICENSE build/
|
|
46
|
+
fi
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function main() {
|
|
50
|
+
parse_arguments "$@"
|
|
51
|
+
if [ ${PROCESS_ARGUMENTS['--help']} ]; then
|
|
52
|
+
usage
|
|
53
|
+
exit 0
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
modify_package_json_for_release
|
|
57
|
+
copy_license_to_build
|
|
58
|
+
copy_changelog_to_build
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
main "$@"
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
source "$(dirname "$0")/../utils.sh" || exit 1
|
|
4
|
+
|
|
5
|
+
PUBLIC_NPMRC=".npmrc.public"
|
|
6
|
+
PRIVATE_NPMRC=".npmrc.private"
|
|
7
|
+
|
|
8
|
+
function usage() {
|
|
9
|
+
cat << END
|
|
10
|
+
Usage:
|
|
11
|
+
${BASH_SOURCE[0]} [--help] [--public] [--second-private-scope="scope_name_starting_with_at_sign"]
|
|
12
|
+
Where:
|
|
13
|
+
help - show usage information and exit
|
|
14
|
+
public - publish the package into the public
|
|
15
|
+
NPM registry
|
|
16
|
+
second-private-scope - name of a second private scope that we want to
|
|
17
|
+
publish in, e.g.
|
|
18
|
+
--second-private-scope="@mservicestech"
|
|
19
|
+
Useful when private package needs to be published
|
|
20
|
+
with same version and same contents with more than
|
|
21
|
+
one package scope
|
|
22
|
+
|
|
23
|
+
Description:
|
|
24
|
+
Publishes the package into a selected package registry.
|
|
25
|
+
By default, the script published as a private package.
|
|
26
|
+
Requires two '.npmrc' configurations to be present:
|
|
27
|
+
- .npmrc.public
|
|
28
|
+
- .npmrc.private
|
|
29
|
+
These files must point to publicly available registry,
|
|
30
|
+
and a private package registry (e.g. GitHub) respectively.
|
|
31
|
+
END
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function use_npmrc() {
|
|
35
|
+
if ! [ -f "$1" ]; then
|
|
36
|
+
printf "Could not find '%s'. Run with '--help' for more information.\n" "$1"
|
|
37
|
+
exit 1
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
\cp "$1" build/.npmrc
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function failure_handler() {
|
|
44
|
+
printf "Publishing failed. See the logs.\n"
|
|
45
|
+
exit 1
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function get_npm_tag() {
|
|
49
|
+
local version=$(jq -r '.version' build/package.json)
|
|
50
|
+
if [[ "$version" == *"-rc."* ]]; then
|
|
51
|
+
echo "rc"
|
|
52
|
+
else
|
|
53
|
+
echo "latest"
|
|
54
|
+
fi
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function main() {
|
|
58
|
+
parse_arguments "$@"
|
|
59
|
+
if [ ${PROCESS_ARGUMENTS['--help']} ]; then
|
|
60
|
+
usage
|
|
61
|
+
exit 0
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
# Get the appropriate npm tag based on version
|
|
65
|
+
local npm_tag=$(get_npm_tag)
|
|
66
|
+
|
|
67
|
+
# Scripts decides to which registry package should be pushed based
|
|
68
|
+
# on namespace from build/package.json 'name' field and based on used
|
|
69
|
+
# .npmrc file
|
|
70
|
+
if [ ${PROCESS_ARGUMENTS['--public']} ]; then
|
|
71
|
+
use_npmrc "$PUBLIC_NPMRC"
|
|
72
|
+
pushd build
|
|
73
|
+
npm publish --access public --tag "$npm_tag" || failure_handler
|
|
74
|
+
elif [ ${PROCESS_ARGUMENTS['--second-private-scope']} ]; then
|
|
75
|
+
# We assume second private scope has already been changed in
|
|
76
|
+
# build/package.json and package is ready to be published with that scope
|
|
77
|
+
use_npmrc "$PRIVATE_NPMRC"
|
|
78
|
+
pushd build
|
|
79
|
+
npm publish --tag "$npm_tag" || failure_handler
|
|
80
|
+
else
|
|
81
|
+
use_npmrc "$PRIVATE_NPMRC"
|
|
82
|
+
pushd build
|
|
83
|
+
npm publish --tag "$npm_tag" || failure_handler
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
popd
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
main "$@"
|