Skip to content

Commit ef39f58

Browse files
committed
rename analyticsConfigFilePath
1 parent 47bf420 commit ef39f58

File tree

8 files changed

+33
-22
lines changed

8 files changed

+33
-22
lines changed

config/build.conf.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ const ROOT = path.join(__dirname, '..');
1111
/**
1212
* The mongosh package.
1313
*/
14-
const MONGOSH = path.join(ROOT, 'packages', 'cli-repl');
14+
const CLI_REPL_DIR = path.join(ROOT, 'packages', 'cli-repl');
1515

1616
/**
1717
* The project config.
1818
*/
19-
const CONFIG = require(path.join(MONGOSH, 'package.json'));
19+
const CLI_REPL_PACKAGE_JSON = require(path.join(CLI_REPL_DIR, 'package.json'));
2020

2121
/**
2222
* The input for the build.
2323
*/
24-
const INPUT = path.join(MONGOSH, 'lib', 'run.js');
24+
const INPUT = path.join(CLI_REPL_DIR, 'lib', 'run.js');
2525

2626
/**
2727
* The input for the exec.
2828
*/
29-
const EXEC_INPUT = path.join(MONGOSH, 'dist', 'mongosh.js');
29+
const EXEC_INPUT = path.join(CLI_REPL_DIR, 'dist', 'mongosh.js');
3030

3131
/**
3232
* The output dir for the build.
@@ -36,7 +36,7 @@ const OUTPUT_DIR = path.join(ROOT, 'dist');
3636
/**
3737
* Analytics configuration file.
3838
*/
39-
const ANALYTICS_CONFIG = path.join(MONGOSH, 'lib', 'analytics-config.js');
39+
const ANALYTICS_CONFIG_FILE_PATH = path.join(CLI_REPL_DIR, 'lib', 'analytics-config.js');
4040

4141
/**
4242
* The bundle id for MacOs.
@@ -56,12 +56,12 @@ const BUILD_VARIANT = (process.env.BUILD_VARIANT || '').split('_')[0];
5656
* Export the configuration for the build.
5757
*/
5858
module.exports = {
59-
version: CONFIG.version,
59+
version: CLI_REPL_PACKAGE_JSON.version,
6060
rootDir: ROOT,
6161
input: INPUT,
6262
execInput: EXEC_INPUT,
6363
outputDir: OUTPUT_DIR,
64-
analyticsConfig: ANALYTICS_CONFIG,
64+
analyticsConfigFilePath: ANALYTICS_CONFIG_FILE_PATH,
6565
project: process.env.PROJECT,
6666
revision: REVISION,
6767
branch: process.env.BRANCH_NAME,

packages/build/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const config = {
5151
input: 'input',
5252
execInput: 'execInput',
5353
outputDir: 'outputDir',
54-
analyticsConfig: 'analyticsConfig',
54+
analyticsConfigFilePath: 'analyticsConfigFilePath',
5555
project: 'project',
5656
revision: 'revision',
5757
branch: 'branch',
@@ -123,15 +123,15 @@ const config = {
123123
input: 'path/to/input',
124124
execInput: 'path/to/exec/input',
125125
outputDir: 'path/to/output/directory',
126-
analyticsConfig: 'path/to/analytics/config',
126+
analyticsConfigFilePath: 'path/to/analytics/config',
127127
segmentKey: 'SEGMENT_API_KEY_23481k',
128128
}
129129
await compileExec(
130130
config.input,
131131
config.execInput,
132132
config.outputDir,
133133
os.platform(),
134-
config.analyticsConfig,
134+
config.analyticsConfigFilePath,
135135
config.segmentKey
136136
);
137137
```

packages/build/src/analytics.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,25 @@ const createAnalyticsConfig = (segmentKey: string): string => {
2222
/**
2323
* Write the analytics config.
2424
*
25-
* @param {string} file - The filename.
25+
* @param {string} analyticsConfigFilePath - The filename.
2626
* @param {string} segmentKey - The segment key.
2727
*/
28-
const writeAnalyticsConfig = (file: string, segmentKey: string): Promise<void> => {
28+
const writeAnalyticsConfig = (
29+
analyticsConfigFilePath?: string,
30+
segmentKey?: string
31+
): Promise<void> => {
32+
if (!analyticsConfigFilePath) {
33+
throw new Error('Analytics config file path is required');
34+
}
35+
36+
if (!segmentKey) {
37+
throw new Error('Segment key is required');
38+
}
39+
2940
const template = createAnalyticsConfig(segmentKey);
30-
console.info('mongosh: writing analytics template:', file);
41+
console.info('mongosh: writing analytics template:', analyticsConfigFilePath);
3142
// Cannot use fs/promises on Cygwin.
32-
return util.promisify(fs.writeFile)(file, template);
43+
return util.promisify(fs.writeFile)(analyticsConfigFilePath, template);
3344
};
3445

3546
export default writeAnalyticsConfig;

packages/build/src/barque.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('Barque', () => {
1919
input: 'input',
2020
execInput: 'execInput',
2121
outputDir: 'outputDir',
22-
analyticsConfig: 'analyticsConfig',
22+
analyticsConfigFilePath: 'analyticsConfigFilePath',
2323
project: 'project',
2424
revision: 'revision',
2525
branch: 'branch',

packages/build/src/compile-exec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ const compileExec = async(
5252
execInput: string,
5353
outputDir: string,
5454
execNodeVersion: string,
55-
analyticsConfig: string,
55+
analyticsConfigFilePath: string,
5656
segmentKey: string): Promise<string> => {
5757
// We use Parcel to bundle up everything into a single JS under
5858
// cli-repl/dist/mongosh.js that the executable generator can use as input.
5959
// This JS also takes care of the analytics config file being written.
60-
await generateInput(input, execInput, analyticsConfig, segmentKey);
60+
await generateInput(input, execInput, analyticsConfigFilePath, segmentKey);
6161

6262
const executable = executablePath(outputDir, os.platform());
6363
console.info('mongosh: creating binary:', executable);

packages/build/src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default interface Config {
77
input: string;
88
execInput: string;
99
outputDir: string;
10-
analyticsConfig?: string;
10+
analyticsConfigFilePath?: string;
1111
rootDir: string;
1212
project?: string;
1313
revision?: string;

packages/build/src/do-upload.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('buildAndRelease', () => {
3232
input: 'input',
3333
execInput: 'execInput',
3434
outputDir: 'outputDir',
35-
analyticsConfig: 'analyticsConfig',
35+
analyticsConfigFilePath: 'analyticsConfigFilePath',
3636
project: 'project',
3737
revision: 'revision',
3838
branch: 'branch',

packages/build/src/generate-input.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import writeAnalyticsConfig from './analytics';
88
*
99
* @param {string} input - The input file to the cli.
1010
* @param {string} execInput - The input file that the exec will compile from.
11-
* @param {string} analyticsConfig - The path to the analytics config file.
11+
* @param {string} analyticsConfigFilePath - The path to the analytics config file.
1212
* @param {string} segmentKey - The segment API key.
1313
*/
14-
async function generateInput(input: string, execInput: string, analyticsConfig: string, segmentKey: string): Promise<void> {
14+
async function generateInput(input: string, execInput: string, analyticsConfigFilePath: string, segmentKey: string): Promise<void> {
1515
// This takes the segment api key and writes it to the
1616
// cli-repl's analytics-config file.
17-
await writeAnalyticsConfig(analyticsConfig, segmentKey);
17+
await writeAnalyticsConfig(analyticsConfigFilePath, segmentKey);
1818

1919
console.info('mongosh: creating bundle:', execInput);
2020

0 commit comments

Comments
 (0)