dcp-client 4.4.15 → 4.4.17

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/build/all ADDED
@@ -0,0 +1,15 @@
1
+ #! /bin/bash -e
2
+
3
+ oldDir="`pwd`"
4
+ cd `dirname $0`
5
+ myDir="`pwd`"
6
+
7
+ if [ ! -d "$myDir/node_modules" ]; then
8
+ cd "$myDir"
9
+ npm ci
10
+ fi
11
+
12
+ cd "$oldDir"
13
+ "${myDir}/generate-sandbox-definitions-json"
14
+ echo
15
+ "${myDir}/bundle" "$@"
package/build/bundle ADDED
@@ -0,0 +1,203 @@
1
+ #! /bin/bash
2
+ #
3
+ # @file build.sh Rebuild the dcp-client bundle without affecting
4
+ # the intermediate files in the dcp repo.
5
+ #
6
+ # Usage: build/bundle.sh <path to dcp repo>
7
+ #
8
+ # @author Wes Garland, wes@distributive.network
9
+ # @date Mar 2020
10
+ #
11
+
12
+ # portable implementation of linux realpath
13
+ realpath()
14
+ {
15
+ (
16
+ filename="$1"
17
+ dirname="`dirname \"$1\"`"
18
+ basename="`basename \"$1\"`"
19
+ [ "$dirname" ] || dirname="."
20
+ cd "$dirname" && echo "`pwd -P`/$basename"
21
+ )
22
+ }
23
+
24
+ argvZero="$0"
25
+ argvRest="$*"
26
+ myDir="`dirname \`realpath $argvZero\``"
27
+
28
+ usage()
29
+ {
30
+ cat <<EOHELP
31
+
32
+ $0 - Rebuild the DCP-Client Bundle
33
+ Copyright (c) 2020-2024 Distributive Corp. All Rights Reserved.
34
+
35
+ Usage: $0 [path to dcp repo] [[--options] ... ]
36
+ Where:
37
+ --help Shows this help
38
+ --dcp=<dir> Sets the DCP source directory
39
+ --build=<debug|release> Sets the DCP build type
40
+ --install-flags=<flags> Sets extra flags used by dcp/install.sh
41
+ -d or --debug Debug the bundle-build process
42
+ --reset Empty the invocation cache
43
+ --no-cache Do not read or update the invocation cache
44
+ Note: Options will be cached as future invocations' defaults.
45
+ EOHELP
46
+ }
47
+
48
+ # Main program entry point
49
+ if [ "$1" ] && [ -d "$1" ]; then
50
+ _DCP_SRC="$1"
51
+ shift
52
+ fi
53
+
54
+ # pre-process args to scan for --no-cache
55
+ cd `dirname "$0"`/..
56
+ NO_CACHE=""
57
+ for opt in "$@"
58
+ do
59
+ if [ "$opt" = "--no-cache" ]; then
60
+ NO_CACHE=1
61
+ echo " * Disabling cache" >&2
62
+ fi
63
+ done
64
+
65
+ [ ! "${NO_CACHE}" ] && [ -f "${myDir}/etc/config.cache" ] && . "${myDir}/etc/config.cache" ]
66
+ [ "${_DCP_SRC}" ] && DCP_SRC="${_DCP_SRC}"
67
+
68
+ while getopts "dh-:" OPTION; do
69
+ if [ "$OPTION" = "-" ]; then
70
+ if [[ "$OPTARG" =~ (^[a-z0-9-]+)=(.*) ]]; then
71
+ OPTION="${BASH_REMATCH[1]}"
72
+ OPTARG="${BASH_REMATCH[2]}"
73
+ else
74
+ OPTION="${OPTARG}"
75
+ OPTARG=""
76
+ fi
77
+ fi
78
+
79
+ OPTFILES="`eval echo \"${OPTARG}\"`"
80
+ [ -f "$OPTFILES" ] && OPTFILE="$OPTFILES" || OPTFILE=""
81
+
82
+ case $OPTION in
83
+ h|help)
84
+ usage
85
+ exit 1
86
+ ;;
87
+ dcp)
88
+ DCP_SRC="${OPTARG}"
89
+ ;;
90
+ install-flags)
91
+ DCP_INSTALL_FLAGS="${DCP_INSTALL_FLAGS} ${OPTARG}"
92
+ ;;
93
+ reset)
94
+ rm -f "${myDir}/etc/config.cache"
95
+ argvRest="`echo \"$argvRest\" | sed -e 's/--reset//' -e 's/^ *//'`"
96
+ [ "$argvRest" ] && exec $SHELL -c "\"$argvZero\" $argvRest"
97
+ exit 99
98
+ ;;
99
+ d|debug)
100
+ DCP_INSTALL_FLAGS="${DCP_INSTALL_FLAGS} -d"
101
+ DEBUG=1
102
+ DEBUG_BUNDLE=1
103
+ ;;
104
+ build)
105
+ [ "$DCP_BUILD" != "$OPTARGS" ] && echo "Setting DCP build type to ${OPTARG}"
106
+ DCP_BUILD="${OPTARG}"
107
+ ;;
108
+ no-cache)
109
+ ;;
110
+ *)
111
+ echo "Unrecognized option: $OPTION"
112
+ exit 2
113
+ ;;
114
+ esac
115
+ done
116
+
117
+ DCP_SRC="`eval echo $DCP_SRC`"
118
+ if [ ! "$DCP_SRC" ] || [ ! -d "$DCP_SRC" ]; then
119
+ echo "Could not locate DCP repo ($DCP_SRC). Once specified, it will be cached for future runs."
120
+ echo "See $0 --help for more information. Stop."
121
+ exit 98
122
+ else
123
+ DCP_SRC="`realpath \"$DCP_SRC\"`"
124
+ fi >/dev/stderr
125
+
126
+ echo "Building DCP Client ${DCP_BUILD} bundle from DCP in ${DCP_SRC}"
127
+
128
+ case "${DCP_BUILD}" in
129
+ debug|release)
130
+ ;;
131
+ *)
132
+ echo "Unknown build type: ${DCP_BUILD}" >/dev/stderr
133
+ exit 96
134
+ esac
135
+
136
+ # Write cache
137
+ [ -d "${myDir}/etc" ] || mkdir -p "${myDir}/etc"
138
+ if [ ! "${NO_CACHE}" ]; then
139
+ cat > "${myDir}/etc/config.cache" << EOF
140
+ DCP_SRC="${DCP_SRC}"
141
+ DCP_INSTALL_FLAGS="${DCP_INSTALL_FLAGS}"
142
+ DCP_BUILD="${DCP_BUILD}"
143
+ EOF
144
+ fi
145
+
146
+ # Create staging folder so we don't make changes in dcp repo dist
147
+ BUNDLE_TMP="`mktemp -d -t XXXXX.dcpClientBuild`"
148
+ [ "$DEBUG_BUNDLE" ] || trap "rm -rf \"${BUNDLE_TMP}\"" EXIT
149
+ [ "$DEBUG_BUNDLE" ] && trap "echo 'Debug Mode: left \"$BUNDLE_TMP\" behind.'" EXIT
150
+ mkdir -p "${BUNDLE_TMP}/dist" || exit $?
151
+
152
+ # Write install.sh override files
153
+ cat > "${BUNDLE_TMP}/local-config.incl" <<EOF
154
+ echo " . Loading DCP local-config extras for dcp-client build/bundle" >&2
155
+ SRC_DIR="${DCP_SRC}"
156
+ DCP_PREFIX="${BUNDLE_TMP}"
157
+ BUILD="${DCP_BUILD}"
158
+ DCP_LOCAL_CONFIG_JSON="${BUNDLE_TMP}/local-config.json"
159
+ EOF
160
+
161
+ node > "${BUNDLE_TMP}/local-config.json" << EOJS
162
+ const localConfig = {};
163
+ localConfig.generated = "`date` by `id -un` on `hostname`";
164
+ if ("${DCP_BUILD}") localConfig.build = "${DCP_BUILD}";
165
+ localConfig.dcpClientDestination = "${BUNDLE_TMP}/dist";
166
+ console.log(JSON.stringify(localConfig));
167
+ EOJS
168
+
169
+ if [ ! -d "${DCP_SRC}/node_modules" ]; then
170
+ echo "Cannot find ${DCP_SRC}/node_modules. Please run npm i from ${DCP_SRC}" >&2
171
+ exit 97
172
+ fi
173
+
174
+ NO_LOG=1 \
175
+ SKIP_SUDO_CHECK=1 \
176
+ DCP_LOCAL_CONFIG_EXTRAS="${BUNDLE_TMP}/local-config.incl" \
177
+ "${DCP_SRC}/install.sh" -NI ${DCP_INSTALL_FLAGS} build-dcp-client
178
+
179
+ EXIT_CODE="$?"
180
+ if [ "$EXIT_CODE" != "0" ]; then
181
+ echo "Error: ${DCP_SRC}/install.sh failed with code $EXIT_CODE. Stop." >&2
182
+ exit 3
183
+ fi
184
+
185
+ echo
186
+ echo "Importing DCP Client Bundle"
187
+ cd "${myDir}/.."
188
+ [ "$?" = "0" ] || exit 4
189
+ [ "${DEBUG}" ] || [ "${DEBUG_BUNDLE}" ] && find "${BUNDLE_TMP}" -ls
190
+
191
+ # Copy all generated files tracked by the repo into this repo
192
+ git ls-tree --full-tree -r --name-only HEAD dist |\
193
+ (cd "${BUNDLE_TMP}" && while read file;
194
+ do
195
+ ls "$file" 2>/dev/null
196
+ done) > "${BUNDLE_TMP}/flist"
197
+
198
+ [ "$DEBUG_BUNDLE" ] && echo "Files to copy:" && cat "${BUNDLE_TMP}/flist" | sed 's/^/ - /'
199
+
200
+ (cd "${BUNDLE_TMP}" && tar -T ./flist -cf -) | tar -xvf - | sed 's/^/ - /'
201
+ STATUS=$?
202
+ echo "Done."
203
+ exit $STATUS
@@ -0,0 +1,3 @@
1
+ DCP_SRC="/home/wes/git/dcp"
2
+ DCP_INSTALL_FLAGS=""
3
+ DCP_BUILD="debug"
@@ -0,0 +1,63 @@
1
+ #! /usr/bin/env node
2
+ 'use strict';
3
+ /**
4
+ * @file generate-sandbox-definitions-json
5
+ * This file is the single-source-of-authority with respect
6
+ * to which files are run for which evaluators. It is used
7
+ * to generate code in ../generated.
8
+ *
9
+ * @author Wes Garland, wes@kingsds.network
10
+ * @date Feb 2021
11
+ */
12
+
13
+ const fs = require('fs');
14
+ const path = require('path');
15
+
16
+ var o = {};
17
+ const target = '../generated/sandbox-definitions.json';
18
+ console.log(`Generating sandbox definitions in ${target}`);
19
+
20
+ /** All sandbox types use the base files */
21
+ const base = [
22
+ 'script-load-wrapper',
23
+ 'timer-classes',
24
+ 'wrap-event-listeners',
25
+ 'event-loop-virtualization',
26
+ 'lift-webgl',
27
+ 'lift-wasm',
28
+ 'lift-webgpu',
29
+ 'worktimes',
30
+ 'access-lists',
31
+ 'bravojs-init',
32
+ 'bravojs/bravo.js',
33
+ 'bravojs-env',
34
+ 'pyodide-core',
35
+ 'calculate-capabilities',
36
+ ];
37
+
38
+ o.browser = [].concat(base);
39
+
40
+ /** A node-evaluator sandbox needs extra code to emulate a Web Worker */
41
+ o.node = ['sa-ww-simulation'].concat(base);
42
+
43
+ /** A native-evaluator sandbox needs extra code to emulate a Web Worker */
44
+ o.native = ['sa-ww-simulation'].concat(base);
45
+ o.native.splice(2, 0, 'native-event-loop');
46
+
47
+ for (let type in o) {
48
+ o[type].unshift('kvin/kvin.js');
49
+ if (type !== 'node')
50
+ o[type].unshift('deny-node');
51
+ o[type].push('bootstrap');
52
+ }
53
+
54
+ /** A node-testing evaluator similar to the node evaluator but with an additional testing script loaded */
55
+ o.nodeTesting = o.node.concat(['testing.js']);
56
+
57
+ /** A testing sandbox is a native sandbox with an additional testing script
58
+ * injected that can be changed to test global symbols in the evaluator
59
+ */
60
+ o.testing = o.native.concat(['testing.js']);
61
+
62
+ fs.writeFileSync(path.resolve(__dirname, target), JSON.stringify(o), 'utf-8');
63
+ console.log(`Done - ${Object.keys(o).join(', ')}.`);
@@ -0,0 +1,74 @@
1
+ #! /usr/bin/env bash
2
+ #
3
+ # @file publish-docs.sh
4
+ # @athor Brandon Christie <brandon@distributive.network>
5
+ # @date Aug 2023
6
+ #
7
+ # @description Publishes the docs for each component
8
+ # to backstage.
9
+
10
+ set -euo pipefail
11
+
12
+ cd "$(dirname "$0")/.."
13
+
14
+ ROOT_DIR=$PWD
15
+
16
+ echo "TechDocs Bucket Name: $TECHDOCS_S3_BUCKET_NAME"
17
+ echo "Namespace: $ENTITY_NAMESPACE"
18
+
19
+ ENTITY_KIND=$(yq ".kind" < catalog-info.yaml)
20
+ echo "Kind: $ENTITY_KIND"
21
+
22
+ ENTITY_NAME=$(yq ".metadata.name" < catalog-info.yaml)
23
+ echo "Name: $ENTITY_NAME"
24
+
25
+ TECHDOCS_REF=$(yq ".metadata.annotations.\"backstage.io/techdocs-ref\"" < catalog-info.yaml)
26
+ echo "TechDocs Ref: $TECHDOCS_REF"
27
+
28
+ # An example of the the techdocs-ref in the YAML file:
29
+ # dir:./docs/dcp
30
+ #
31
+ # The Regex below will isolate the directory path giving the
32
+ # result 'docs/dcp' for the given example.
33
+ if [[ "$TECHDOCS_REF" =~ dir:\.(.*) ]]; then
34
+ RELATIVE_DOCS_DIR="${BASH_REMATCH[1]%%[[:space:]]*}"
35
+ DOCS_DIR="$ROOT_DIR/$RELATIVE_DOCS_DIR"
36
+ fi
37
+
38
+ # The techdocs-cli commands must be called in the directory where the
39
+ # mkdocs.yml file is present.
40
+ cd "$DOCS_DIR"
41
+
42
+ # MkDocs requires an index.md or README.md file, if one does not exist it will
43
+ # be generated automatically.
44
+ if ! [ -f index.md ] && ! [ -f README.md ]; then
45
+ if [ -z "$CI" ]; then
46
+ AUTHOR="$(git config user.name) <$(git config user.email)>"
47
+ else
48
+ AUTHOR="$CI_COMMIT_AUTHOR"
49
+ fi
50
+
51
+ echo "README.md or index.md was not found and will be automatically generated."
52
+ cat >> index.md <<EOF
53
+ <!--
54
+ @author $AUTHOR
55
+ @date $(date)
56
+ @machine $HOSTNAME
57
+ @rev $(git rev-parse HEAD)
58
+ -->
59
+ > **Warning**: MkDocs requires a top level index.md or README.md (case sensitive)
60
+ This index.md file has been generated automatically to ensure MkDocs works correctly
61
+ EOF
62
+ fi
63
+
64
+ npx techdocs-cli generate --no-docker --verbose
65
+
66
+ npx techdocs-cli publish \
67
+ --publisher-type awsS3 \
68
+ --storage-name "$TECHDOCS_S3_BUCKET_NAME" \
69
+ --entity "$ENTITY_NAMESPACE"/"$ENTITY_KIND"/"$ENTITY_NAME" \
70
+ --directory "$DOCS_DIR"/site
71
+
72
+ rm -r "$DOCS_DIR"/site
73
+
74
+ echo "View generated component: https://backstage.overwatch.distributive.network/docs/default/component/$ENTITY_NAME"