Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
 
# This script makes NPM packages for onnxruntime-common and onnxruntime-(node|web|react-native)
#
# Release Mode (release):
#   Do not update version number. Version number should be matching $(ORT_ROOT)/VERSION_NUMBER
#   Always generate packages for onnxruntime-common and onnxruntime-(node|web|react-native)
#
# Release Candidate Mode (rc):
#   Update version number to {VERSION_BASE}-rc.{YYYYMMDD}-{COMMIT}
#   Always generate packages for onnxruntime-common and onnxruntime-(node|web|react-native)
#
# Dev Mode (dev):
#   Compare current content with latest @dev package for onnxruntime-common. If no change, we
#   don't publish a new version of onnxruntime-common. Instead, we update the dependency version
#   to use the existing version.
#   Update version number to {VERSION_BASE}-dev.{YYYYMMDD}-{COMMIT}
#
# Custom Mode:
#   Use first commandline parameter as version number suffix.
#   Always generate packages for onnxruntime-common and onnxruntime-(node|web|react-native)
#
 
if ($Args.Count -lt 3) {
    throw "This script requires at least 3 arguments, but got $($Args.Count)"
}
$MODE=$Args[0] # "dev" or "release" or "rc"; otherwise it is considered as a version number
$ORT_ROOT=$Args[1] # eg. D:\source\onnxruntime
$TARGET=$Args[2] # "node" or "web" or "react_native"
 
if ($TARGET -ne "node" -and $TARGET -ne "web" -and $TARGET -ne "react_native") {
    throw "Invalid target: $TARGET. Must be one of 'node', 'web' or 'react_native'"
}
if ($TARGET -ne "node" -and $Args.Count -gt 3) {
    throw "Invalid argument count: $($Args.Count). Only 3 arguments are allowed for target '$TARGET'"
}
$VERSION_CANDIDATES=$Args[3] # optional, only for node target
if ($TARGET -eq "node" -and $Args.Count -gt 4) {
    throw "Invalid argument count: $($Args.Count). Only 4 arguments are allowed for target '$TARGET'"
}
 
Function Generate-Package-Version-Number {
    pushd $ORT_ROOT
    $version_base=Get-Content ./VERSION_NUMBER
    $version_timestamp=git show -s --format=%ct HEAD
    $version_commit=git rev-parse HEAD
    $version_commit_short=git rev-parse --short HEAD
    popd
    $version_date=[DateTimeOffset]::FromUnixTimeSeconds($version_timestamp).ToString("yyyyMMdd")
    if ($MODE -eq 'dev') {
        $version_number="$version_base-dev.$version_date-$version_commit_short"
    } elseif ($MODE -eq 'rc') {
        $version_number="$version_base-rc.$version_date-$version_commit_short"
    } elseif ($MODE -eq 'release')  {
        $version_number="$version_base"
    } else {
        $version_number="$version_base$MODE"
    }
 
    Write-Host "Generated version number for '$MODE': $version_number"
    return @{ version = $version_number; commit = $version_commit }
}
 
$JS_COMMON_DIR=Join-Path -Path "$ORT_ROOT" -ChildPath "js/common"
$JS_TARGET_DIR=Join-Path -Path "$ORT_ROOT" -ChildPath "js/$TARGET"
 
if ($MODE -eq "dev") {
    # For @dev builds, we compares the following 2 package versions for onnxruntime-common:
    # - 'current': the version we are currently building.
    # - 'latest': the latest @dev version from npm.js repository.
    #
    # If the contents of the 2 versions are identical, we don't publish a new version. Instead,
    # we only publish onnxruntime-node/onnxruntime-web/onnxruntime-react-native and
    # set its dependency's version to the 'latest'.
 
    # check latest @dev version
    Write-Host "Start checking version for onnxruntime-common@dev"
    npm view onnxruntime-common@dev --json | Out-File -Encoding utf8 ./ort_common_latest_info.json
    $ort_common_latest_version=node -p "require('./ort_common_latest_info.json').version"
    Write-Host "latest version is: $ort_common_latest_version"
 
    # download package latest@dev
    $packed_filename=npm pack "onnxruntime-common@dev"
    if (!(Test-Path $packed_filename)) {
        throw "npm pack failed to produce: $packed_filename"
    }
    Rename-Item $packed_filename ./latest.tgz
    Write-Host "Tarball downloaded"
 
    # generate @dev version
    $version_number=Generate-Package-Version-Number
 
    # make package for latest
    pushd $JS_COMMON_DIR
    npm version --allow-same-version $ort_common_latest_version
    echo $($version_number.commit) | Out-File -Encoding ascii -NoNewline -FilePath ./__commit.txt
    # update version.ts of common
    pushd ..
    npm run update-version common
    npm run format
    popd
    npm pack
    popd
 
    $current_tgz_compare_only=Join-Path -Path "$JS_COMMON_DIR" -ChildPath "onnxruntime-common-$ort_common_latest_version.tgz"
    if (!(Test-Path $current_tgz_compare_only)) {
        throw "File is not generated: $current_tgz_compare_only"
    }
    Write-Host "Package file ready for comparing: $current_tgz_compare_only"
 
    # extract packages
    mkdir ./latest
    pushd ./latest
    tar -xzf ../latest.tgz
    rm ../latest.tgz
    popd
 
    mkdir ./current
    pushd ./current
    tar -xzf $current_tgz_compare_only
    rm $current_tgz_compare_only
    popd
 
    # setup temp folder to compare
    mkdir ./temp
    pushd ./temp
    npm init -y
    npm install "dir-compare-cli@1.0.1" "json-diff@0.5.4"
 
    Write-Host "Compare package.json"
    $latest_package_json=Join-Path -Path ".." -ChildPath "latest/package/package.json"
    $current_package_json=Join-Path -Path ".." -ChildPath "current/package/package.json"
    npx json-diff $latest_package_json $current_package_json
    $use_latest=$?
    Write-Host "Result: $use_latest"
    if ($use_latest) {
        # package.json matches. now check package contents.
 
        # do not compare commit number
        $latest_package_commit=Join-Path -Path ".." -ChildPath "latest/package/__commit.txt"
        $current_package_commit=Join-Path -Path ".." -ChildPath "current/package/__commit.txt"
        if (test-path $latest_package_commit) { rm $latest_package_commit }
        if (test-path $current_package_commit) { rm $current_package_commit }
        # skip package.json, we already checked them
        rm $latest_package_json
        rm $current_package_json
 
        Write-Host "Compare package contents"
        $latest_package_dir=Join-Path -Path ".." -ChildPath "latest/package"
        $current_package_dir=Join-Path -Path ".." -ChildPath "current/package"
        npx dircompare -c $latest_package_dir $current_package_dir
        $use_latest=$?
        Write-Host "Result: $use_latest"
    }
 
    popd
 
    if (!$use_latest) {
        Write-Host "Need update to onnxruntime-common@dev"
        # need to publish a new version for onnxruntime-common
        pushd $JS_COMMON_DIR
        npm version --allow-same-version $($version_number.version)
        # file __commit.txt is already generated
 
        # update version.ts of common
        pushd ..
        npm run update-version common
        npm run format
        popd
 
        npm pack
        popd
    }
 
    # make package for target
    pushd $JS_TARGET_DIR
    npm version --allow-same-version $($version_number.version)
    echo $($version_number.commit) | Out-File -Encoding ascii -NoNewline -FilePath ./__commit.txt
 
    # update version.ts of TARGET
    pushd ..
    npm run update-version $TARGET $VERSION_CANDIDATES
    npm run format
    popd
 
    npm pack
    popd
} elseif ($MODE -eq "release") {
    # release mode. always publish new package
    pushd $JS_COMMON_DIR
    npm pack
    popd
    pushd $JS_TARGET_DIR
    npm pack
    popd
} else {
    # release candidate mode or custom mode. always publish new package
    $version_number=Generate-Package-Version-Number
 
    pushd $JS_COMMON_DIR
    npm version --allow-same-version $($version_number.version)
 
    # update version.ts of common
    pushd ..
    npm run update-version common
    npm run format
    popd
 
    npm pack
    popd
 
    pushd $JS_TARGET_DIR
    npm version --allow-same-version $($version_number.version)
 
    # update version.ts of TARGET
    pushd ..
    npm run update-version $TARGET
    npm run format
    popd
 
    npm pack
    popd
}