Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
// This script update the following source files:
// - /js/${arg0}/lib/version.ts
// - /js/node/script/install-metadata-versions.js (only for arg0=="node")
//
// version data is read from file /js/${arg0}/package.json
 
import fs from 'fs-extra';
import path from 'path';
 
const packageName = process.argv[2];
if (['common', 'web', 'node', 'react_native'].indexOf(packageName) === -1) {
  throw new Error('expect arg0 to be one of: common,web,node,react_native');
}
 
const PACKAGE_JSON_FILE = path.join(__dirname, '..', packageName, 'package.json');
const version = JSON.parse(fs.readFileSync(PACKAGE_JSON_FILE).toString()).version;
 
if (typeof version !== 'string') {
  throw new Error(`failed to parse "version" from file: ${PACKAGE_JSON_FILE}`);
}
 
{
  // update /js/${arg0}/lib/version.ts
  const FILE_CONTENT = `// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
// This file is generated by /js/scripts/update-version.ts
// Do not modify file content manually.
 
export const version = ${JSON.stringify(version)};
`;
 
  fs.writeFileSync(path.join(__dirname, '..', packageName, 'lib', 'version.ts'), FILE_CONTENT);
}
 
if (packageName === 'node') {
  // update /js/node/script/install-metadata-versions.js
 
  // If there is a second argument, use it as the version candidates. Otherwise, use the version from package.json.
  // ";" will be used as the separator.
  const versionCandidates = (process.argv[3] ?? '')
    .split(';')
    .map((v) => v.trim())
    .filter((v) => !!v);
 
  type NodeInstallMetadataVersions = Record<string, Array<{ feed: string; version: string }>>;
  const versions: NodeInstallMetadataVersions = { nuget: [] };
 
  if (versionCandidates.length > 0) {
    // append dev versions
    for (const v of versionCandidates) {
      versions.nuget.push({
        feed: 'nuget_nightly',
        version: v,
      });
    }
  } else {
    // append release version
    versions.nuget.push({
      feed: 'nuget',
      version,
    });
  }
 
  const FILE_CONTENT = `// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
// This file is generated by /js/scripts/update-version.ts
// Do not modify file content manually.
 
module.exports = ${JSON.stringify(versions)};
`;
  fs.writeFileSync(path.join(__dirname, '..', 'node', 'script', 'install-metadata-versions.js'), FILE_CONTENT);
}