Skip to content

Commit fac6b23

Browse files
committed
AGPLv3 license header on all files
1 parent f84ed98 commit fac6b23

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1054
-1082
lines changed

src/config/Config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
// Common Identifier Application
2+
// Copyright (C) 2024 World Food Programme
3+
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
117
export namespace Config {
218
export interface Column {
319
name: string;

src/config/appConfig.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
/*
2-
* This file is part of Building Blocks CommonID Tool
3-
* Copyright (c) 2024 WFP
4-
*
5-
* This program is free software: you can redistribute it and/or modify
6-
* it under the terms of the GNU General Public License as published by
7-
* the Free Software Foundation, version 3.
8-
*
9-
* This program is distributed in the hope that it will be useful, but
10-
* WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12-
* General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU General Public License
15-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
*/
1+
// Common Identifier Application
2+
// Copyright (C) 2024 World Food Programme
3+
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1716

1817
import fs from 'node:fs';
1918
import { attemptToReadTOMLData } from './utils.js';

src/config/configStore.ts

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
/*
2-
* This file is part of Building Blocks CommonID Tool
3-
* Copyright (c) 2024 WFP
4-
*
5-
* This program is free software: you can redistribute it and/or modify
6-
* it under the terms of the GNU General Public License as published by
7-
* the Free Software Foundation, version 3.
8-
*
9-
* This program is distributed in the hope that it will be useful, but
10-
* WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12-
* General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU General Public License
15-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
*/
17-
18-
import { join, dirname } from 'node:path';
19-
import { fileURLToPath } from 'node:url';
1+
// Common Identifier Application
2+
// Copyright (C) 2024 World Food Programme
3+
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
import { dirname } from 'node:path';
2018
import fs from 'node:fs';
2119
import Debug from 'debug';
2220
const log = Debug('CID:ConfigStore');
@@ -29,7 +27,7 @@ import type { AppConfigData, Config } from './Config.js';
2927
// Ensure the application's config file directory exists
3028
function ensureAppDirectoryExists(appDir: string) {
3129
if (!fs.existsSync(appDir)) {
32-
console.log("Application directory '", appDir, "' does not exits -- creating it");
30+
log("Application directory '", appDir, "' does not exits -- creating it");
3331
fs.mkdirSync(appDir /*, { recursive: true } */);
3432
}
3533
}
@@ -42,7 +40,7 @@ function saveConfig(configData: Config.Options, outputPath: string) {
4240
// update the config hash on import to account for the
4341
const outputData = JSON.stringify(configData, null, ' ');
4442
fs.writeFileSync(outputPath, outputData, CONFIG_FILE_ENCODING);
45-
console.log('Written config data to ', outputPath);
43+
log('Written config data to ', outputPath);
4644
}
4745

4846
interface ConfigStorePaths {
@@ -110,20 +108,20 @@ export class ConfigStore {
110108
// if the load succesds we have a valid config -- use it as a
111109
// user-provided one
112110
if (userConfigLoad.success) {
113-
console.log('User config validation success - using it as config');
111+
log('User config validation success - using it as config');
114112
this.useUserConfig(userConfigLoad.config, userConfigLoad.lastUpdated);
115113
return;
116114
}
117115

118-
console.log('User config validation not successful - attempting to load backup config');
116+
log('User config validation not successful - attempting to load backup config');
119117
// if the default config load failed use the backup default
120118
// from the app distribution
121119
const backupConfigLoad = loadConfig(this.getBackupConfigFilePath(), this.getRegion());
122120

123121
// if the load succesds we have a valid config -- use it as
124122
// a config-from-backup
125123
if (backupConfigLoad.success) {
126-
console.log('Backup config validation success - using it as config');
124+
log('Backup config validation success - using it as config');
127125
backupConfigLoad.config.isBackup = true;
128126
this.useBackupConfig(backupConfigLoad.config);
129127
return;
@@ -133,7 +131,7 @@ export class ConfigStore {
133131
this.loadError = backupConfigLoad.error;
134132

135133
// if the backup config fails to load we are screwed
136-
console.log(
134+
log(
137135
'Backup config load failed - the application should alert the user: ',
138136
backupConfigLoad.error,
139137
);
@@ -178,21 +176,21 @@ export class ConfigStore {
178176
// This method does not save the backup as the user config, only deletes the user config file
179177
removeUserConfig() {
180178
// attempt to load the backup config
181-
console.log('[removeUserConfig] Attempting to remove user configuration and replace with backup.');
179+
log('[removeUserConfig] Attempting to remove user configuration and replace with backup.');
182180

183181
// if the current config is already a backup config don't do anything
184182
if (this.isCurrentConfigBackup()) {
185-
console.log('[removeUserConfig] Already using a backup config -- bailing');
183+
log('[removeUserConfig] Already using a backup config -- bailing');
186184
// this is not an error - we're already using the backup
187185
return;
188186
}
189187

190-
console.log('[removeUserConfig] Trying to load backup config file');
188+
log('[removeUserConfig] Trying to load backup config file');
191189
const backupConfigLoad = loadConfig(this.getBackupConfigFilePath(), this.getRegion());
192190

193191
// if failed return the error message (do not delete the user config yet)
194192
if (!backupConfigLoad.success) {
195-
console.log(
193+
log(
196194
'Backup config validation failed -- returning error and keeping existing user config:',
197195
backupConfigLoad.error,
198196
);
@@ -203,7 +201,7 @@ export class ConfigStore {
203201
}
204202

205203
// if successful use the loaded backup configuration
206-
console.log('[removeUserConfig] Backup config validation success - using it as config');
204+
log('[removeUserConfig] Backup config validation success - using it as config');
207205
backupConfigLoad.config.isBackup = true;
208206
this.useBackupConfig(backupConfigLoad.config);
209207

@@ -244,7 +242,7 @@ export class ConfigStore {
244242
// deletes the user configuration file
245243
_deleteUserConfigFile() {
246244
const configPath = this.getConfigFilePath();
247-
console.log('Deleting config file: ', configPath);
245+
log('Deleting config file: ', configPath);
248246
fs.unlinkSync(configPath);
249247
}
250248

src/config/generateConfigHash.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
/*
2-
* This file is part of Building Blocks CommonID Tool
3-
* Copyright (c) 2024 WFP
4-
*
5-
* This program is free software: you can redistribute it and/or modify
6-
* it under the terms of the GNU General Public License as published by
7-
* the Free Software Foundation, version 3.
8-
*
9-
* This program is distributed in the hope that it will be useful, but
10-
* WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12-
* General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU General Public License
15-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
*/
1+
// Common Identifier Application
2+
// Copyright (C) 2024 World Food Programme
3+
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1716

1817
import stableStringify from 'safe-stable-stringify';
1918
import { createHash } from 'node:crypto';
@@ -22,9 +21,7 @@ import type { Config } from './Config.js';
2221
const DEFAULT_HASH_TYPE = 'md5';
2322
const HASH_DIGEST_TYPE = 'hex';
2423

25-
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
2624
type RecursivePartial<T> = { [P in keyof T]?: RecursivePartial<T[P]> };
27-
type RecursivePartialExcept<T, K extends keyof T> = RecursivePartial<T> & Pick<T, K>;
2825

2926
// Takes a config, removes the "signature" and salt keys from it, generates
3027
// a stable JSON representation and hashes it using the provided algorithm

src/config/loadConfig.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
/*
2-
* This file is part of Building Blocks CommonID Tool
3-
* Copyright (c) 2024 WFP
4-
*
5-
* This program is free software: you can redistribute it and/or modify
6-
* it under the terms of the GNU General Public License as published by
7-
* the Free Software Foundation, version 3.
8-
*
9-
* This program is distributed in the hope that it will be useful, but
10-
* WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12-
* General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU General Public License
15-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
*/
1+
// Common Identifier Application
2+
// Copyright (C) 2024 World Food Programme
3+
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1716

1817
import fs from 'node:fs';
1918

src/config/loadSaltFile.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
/*
2-
* This file is part of Building Blocks CommonID Tool
3-
* Copyright (c) 2024 WFP
4-
*
5-
* This program is free software: you can redistribute it and/or modify
6-
* it under the terms of the GNU General Public License as published by
7-
* the Free Software Foundation, version 3.
8-
*
9-
* This program is distributed in the hope that it will be useful, but
10-
* WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12-
* General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU General Public License
15-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
*/
1+
// Common Identifier Application
2+
// Copyright (C) 2024 World Food Programme
3+
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1716
import fs from 'node:fs';
1817
import path from 'node:path';
1918
import Debug from 'debug';

src/config/utils.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
/*
2-
* This file is part of Building Blocks CommonID Tool
3-
* Copyright (c) 2024 WFP
4-
*
5-
* This program is free software: you can redistribute it and/or modify
6-
* it under the terms of the GNU General Public License as published by
7-
* the Free Software Foundation, version 3.
8-
*
9-
* This program is distributed in the hope that it will be useful, but
10-
* WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12-
* General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU General Public License
15-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
*/
1+
// Common Identifier Application
2+
// Copyright (C) 2024 World Food Programme
3+
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1716

1817
import fs from 'node:fs';
1918
import os from 'node:os';

src/config/validateConfig.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
/*
2-
* This file is part of Building Blocks CommonID Tool
3-
* Copyright (c) 2024 WFP
4-
*
5-
* This program is free software: you can redistribute it and/or modify
6-
* it under the terms of the GNU General Public License as published by
7-
* the Free Software Foundation, version 3.
8-
*
9-
* This program is distributed in the hope that it will be useful, but
10-
* WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12-
* General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU General Public License
15-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
*/
1+
// Common Identifier Application
2+
// Copyright (C) 2024 World Food Programme
3+
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1716

1817
import { isRegExp } from 'util/types';
1918
import type { Config } from './Config.js';

0 commit comments

Comments
 (0)