Skip to content

Commit f9241ec

Browse files
authored
Merge branch 'master' into no-envars
2 parents daa7cde + 926f62c commit f9241ec

File tree

18 files changed

+134
-50
lines changed

18 files changed

+134
-50
lines changed

.github/workflows/test-deploy.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,9 @@ jobs:
104104
- run: npm ${{ inputs.release && 'publish' || 'publish --dry-run' }}
105105
env:
106106
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
107-
- run: |
108-
sudo apt install --yes libplist-dev
109-
git clone --branch v2.1.5 git://git.saurik.com/ldid.git
110-
sudo g++ -pipe -o /usr/bin/ldid ldid/ldid.cpp -I. -x c ldid/{lookup2.c,sha1.h} -lplist -lcrypto
107+
# Step required "thanks" to https://github.com/actions/runner-images/issues/6283
108+
- uses: Homebrew/actions/setup-homebrew@29b2973f18e5aca5443f4b3d87f68eda7a27b22b
109+
- run: brew install ldid
111110
- run: |
112111
cp node_modules/@npcz/magic/dist/magic.mgc assets/magic.mgc
113112
npx --yes pkg --no-bytecode --public-packages "*" --public package.json

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ WORKDIR ${CML_RUNNER_PATH}
116116
# SET SPECIFIC ENVIRONMENT VARIABLES
117117
ENV IN_DOCKER=1
118118
ENV RUNNER_ALLOW_RUNASROOT=1
119+
# Environment variable used by cml to detect it's been installed using the docker image.
120+
ENV _CML_CONTAINER_IMAGE=true
119121

120122
# DEFINE ENTRY POINT AND COMMAND
121123
# Smart entrypoint understands commands like `bash` or `/bin/sh` but defaults to `cml`;

bin/cml.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ const setupOpts = (opts) => {
4848

4949
const { markdownfile } = opts;
5050
opts.markdownFile = markdownfile;
51-
opts.cmlCommand = opts._[0];
5251
opts.cml = new CML(opts);
5352
};
5453

@@ -76,9 +75,29 @@ const setupLogger = (opts) => {
7675
});
7776
};
7877

79-
const setupTelemetry = async (opts) => {
80-
const { cml, cmlCommand: action } = opts;
81-
opts.telemetryEvent = await jitsuEventPayload({ action, cml });
78+
const setupTelemetry = async (opts, yargs) => {
79+
const { cml, _: command } = opts;
80+
81+
const options = {};
82+
for (const [name, option] of Object.entries(opts.options)) {
83+
// Skip options with default values (i.e. not explicitly set by users)
84+
if (opts[name] && !yargs.parsed.defaulted[name]) {
85+
switch (option.telemetryData) {
86+
case 'name':
87+
options[name] = null;
88+
break;
89+
case 'full':
90+
options[name] = opts[name];
91+
break;
92+
}
93+
}
94+
}
95+
96+
opts.telemetryEvent = await jitsuEventPayload({
97+
action: command.join(':'),
98+
extra: { options },
99+
cml
100+
});
82101
};
83102

84103
const runPlugin = async ({ $0: executable, command }) => {
@@ -99,6 +118,7 @@ const handleError = (message, error) => {
99118

100119
(async () => {
101120
setupLogger({ log: 'debug' });
121+
102122
try {
103123
await yargs
104124
.env('CML')

bin/cml/asset/publish.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ exports.handler = async (opts) => {
2323
else await fs.writeFile(file, output);
2424
};
2525

26-
exports.builder = (yargs) => yargs.env('CML_ASSET').options(exports.options);
26+
exports.builder = (yargs) =>
27+
yargs
28+
.env('CML_ASSET')
29+
.option('options', { default: exports.options, hidden: true })
30+
.options(exports.options);
2731

2832
exports.options = kebabcaseKeys({
2933
url: {
@@ -51,7 +55,8 @@ exports.options = kebabcaseKeys({
5155
},
5256
rmWatermark: {
5357
type: 'boolean',
54-
description: 'Avoid CML watermark.'
58+
description: 'Avoid CML watermark.',
59+
telemetryData: 'name'
5560
},
5661
mimeType: {
5762
type: 'string',

bin/cml/check/create.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ exports.handler = async (opts) => {
1010
await cml.checkCreate({ ...opts, report });
1111
};
1212

13-
exports.builder = (yargs) => yargs.env('CML_CHECK').options(exports.options);
13+
exports.builder = (yargs) =>
14+
yargs
15+
.env('CML_CHECK')
16+
.option('options', { default: exports.options, hidden: true })
17+
.options(exports.options);
1418

1519
exports.options = kebabcaseKeys({
1620
token: {

bin/cml/comment/create.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ exports.handler = async (opts) => {
88
console.log(await cml.commentCreate(opts));
99
};
1010

11-
exports.builder = (yargs) => yargs.env('CML_COMMENT').options(exports.options);
11+
exports.builder = (yargs) =>
12+
yargs
13+
.env('CML_COMMENT')
14+
.option('options', { default: exports.options, hidden: true })
15+
.options(exports.options);
1216

1317
exports.options = kebabcaseKeys({
1418
pr: {
@@ -30,7 +34,8 @@ exports.options = kebabcaseKeys({
3034
publishUrl: {
3135
type: 'string',
3236
default: 'https://asset.cml.dev',
33-
description: 'Self-hosted image server URL'
37+
description: 'Self-hosted image server URL',
38+
telemetryData: 'name'
3439
},
3540
watch: {
3641
type: 'boolean',
@@ -44,7 +49,8 @@ exports.options = kebabcaseKeys({
4449
native: {
4550
type: 'boolean',
4651
description:
47-
"Uses driver's native capabilities to upload assets instead of CML's storage; not available on GitHub"
52+
"Uses driver's native capabilities to upload assets instead of CML's storage; not available on GitHub",
53+
telemetryData: 'name'
4854
},
4955
update: {
5056
type: 'boolean',
@@ -55,6 +61,7 @@ exports.options = kebabcaseKeys({
5561
rmWatermark: {
5662
type: 'boolean',
5763
description:
58-
'Avoid watermark; CML needs a watermark to be able to distinguish CML comments from others'
64+
'Avoid watermark; CML needs a watermark to be able to distinguish CML comments from others',
65+
telemetryData: 'name'
5966
}
6067
});

bin/cml/pr.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ exports.builder = (yargs) =>
1616
])
1717
)
1818
)
19+
.option('options', { default: options, hidden: true })
1920
.check(({ globpath }) => globpath)
2021
.strict();

bin/cml/pr/create.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ exports.handler = async (opts) => {
1515
console.log(link);
1616
};
1717

18-
exports.builder = (yargs) => yargs.env('CML_PR').options(exports.options);
18+
exports.builder = (yargs) =>
19+
yargs
20+
.env('CML_PR')
21+
.option('options', { default: exports.options, hidden: true })
22+
.options(exports.options);
1923

2024
exports.options = kebabcaseKeys({
2125
md: {

bin/cml/repo/prepare.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ exports.handler = async (opts) => {
1010
await cml.ci(opts);
1111
};
1212

13-
exports.builder = (yargs) => yargs.env('CML_REPO').options(exports.options);
13+
exports.builder = (yargs) =>
14+
yargs
15+
.env('CML_REPO')
16+
.option('options', { default: exports.options, hidden: true })
17+
.options(exports.options);
1418

1519
exports.options = kebabcaseKeys({
1620
unshallow: {

bin/cml/runner.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ exports.builder = (yargs) =>
1616
])
1717
)
1818
)
19+
.option('options', { default: options, hidden: true })
1920
.check(() => process.argv.some((arg) => arg.startsWith('-')))
2021
.strict();

0 commit comments

Comments
 (0)