@babylonjs/smart-filters 1.0.12 → 8.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockFoundation/aggregateBlock.d.ts +3 -3
- package/dist/blockFoundation/aggregateBlock.d.ts.map +1 -1
- package/dist/blockFoundation/aggregateBlock.js +1 -2
- package/dist/blockFoundation/aggregateBlock.js.map +1 -1
- package/dist/blockFoundation/baseBlock.d.ts +2 -2
- package/dist/blockFoundation/baseBlock.d.ts.map +1 -1
- package/dist/blockFoundation/baseBlock.js +5 -6
- package/dist/blockFoundation/baseBlock.js.map +1 -1
- package/dist/blockFoundation/customAggregateBlock.d.ts.map +1 -1
- package/dist/blockFoundation/customAggregateBlock.js +2 -2
- package/dist/blockFoundation/customAggregateBlock.js.map +1 -1
- package/dist/blockFoundation/customShaderBlock.d.ts.map +1 -1
- package/dist/blockFoundation/customShaderBlock.js +4 -6
- package/dist/blockFoundation/customShaderBlock.js.map +1 -1
- package/dist/blockFoundation/disableableShaderBlock.d.ts.map +1 -1
- package/dist/blockFoundation/disableableShaderBlock.js +4 -4
- package/dist/blockFoundation/disableableShaderBlock.js.map +1 -1
- package/dist/blockFoundation/index.js +0 -2
- package/dist/blockFoundation/index.js.map +1 -1
- package/dist/blockFoundation/inputBlock.d.ts +8 -8
- package/dist/blockFoundation/inputBlock.d.ts.map +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.d.ts +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.d.ts.map +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.js +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.js.map +1 -1
- package/dist/blockFoundation/inputBlock.js +7 -7
- package/dist/blockFoundation/inputBlock.js.map +1 -1
- package/dist/blockFoundation/inputBlock.serialization.types.d.ts.map +1 -1
- package/dist/blockFoundation/inputBlock.serializer.d.ts +1 -1
- package/dist/blockFoundation/inputBlock.serializer.js +26 -28
- package/dist/blockFoundation/inputBlock.serializer.js.map +1 -1
- package/dist/blockFoundation/outputBlock.d.ts +4 -9
- package/dist/blockFoundation/outputBlock.d.ts.map +1 -1
- package/dist/blockFoundation/outputBlock.js +13 -14
- package/dist/blockFoundation/outputBlock.js.map +1 -1
- package/dist/blockFoundation/shaderBlock.d.ts +4 -4
- package/dist/blockFoundation/shaderBlock.d.ts.map +1 -1
- package/dist/blockFoundation/shaderBlock.js +13 -19
- package/dist/blockFoundation/shaderBlock.js.map +1 -1
- package/dist/blockFoundation/textureOptions.d.ts +1 -1
- package/dist/blockFoundation/textureOptions.js +1 -1
- package/dist/command/command.d.ts +1 -1
- package/dist/command/command.js +1 -1
- package/dist/command/commandBuffer.d.ts +1 -1
- package/dist/command/commandBuffer.d.ts.map +1 -1
- package/dist/command/commandBuffer.js +2 -2
- package/dist/command/commandBufferDebugger.d.ts +2 -2
- package/dist/command/commandBufferDebugger.d.ts.map +1 -1
- package/dist/command/commandBufferDebugger.js +1 -1
- package/dist/command/commandBufferDebugger.js.map +1 -1
- package/dist/command/index.d.ts +3 -1
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +5 -1
- package/dist/command/index.js.map +1 -1
- package/dist/connection/connectionPoint.d.ts +3 -3
- package/dist/connection/connectionPoint.d.ts.map +1 -1
- package/dist/connection/connectionPoint.js +2 -2
- package/dist/connection/connectionPoint.js.map +1 -1
- package/dist/connection/connectionPointCompatibilityState.d.ts +1 -1
- package/dist/connection/connectionPointCompatibilityState.js +1 -1
- package/dist/connection/connectionPointType.d.ts +3 -3
- package/dist/connection/connectionPointType.d.ts.map +1 -1
- package/dist/connection/connectionPointWithDefault.d.ts +3 -3
- package/dist/connection/connectionPointWithDefault.d.ts.map +1 -1
- package/dist/connection/connectionPointWithDefault.js.map +1 -1
- package/dist/connection/index.d.ts +2 -1
- package/dist/connection/index.d.ts.map +1 -1
- package/dist/connection/index.js +3 -3
- package/dist/connection/index.js.map +1 -1
- package/dist/editorUtils/editableInPropertyPage.d.ts +2 -2
- package/dist/editorUtils/editableInPropertyPage.d.ts.map +1 -1
- package/dist/editorUtils/editableInPropertyPage.js +2 -2
- package/dist/editorUtils/editableInPropertyPage.js.map +1 -1
- package/dist/editorUtils/index.d.ts +1 -0
- package/dist/editorUtils/index.d.ts.map +1 -1
- package/dist/editorUtils/index.js +2 -0
- package/dist/editorUtils/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/optimization/dependencyGraph.js.map +1 -1
- package/dist/optimization/optimizedShaderBlock.d.ts +4 -4
- package/dist/optimization/optimizedShaderBlock.d.ts.map +1 -1
- package/dist/optimization/optimizedShaderBlock.js.map +1 -1
- package/dist/optimization/smartFilterOptimizer.d.ts +2 -2
- package/dist/optimization/smartFilterOptimizer.d.ts.map +1 -1
- package/dist/optimization/smartFilterOptimizer.js +34 -57
- package/dist/optimization/smartFilterOptimizer.js.map +1 -1
- package/dist/runtime/index.d.ts +2 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +3 -3
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/renderTargetGenerator.d.ts +1 -1
- package/dist/runtime/renderTargetGenerator.d.ts.map +1 -1
- package/dist/runtime/renderTargetGenerator.js +5 -7
- package/dist/runtime/renderTargetGenerator.js.map +1 -1
- package/dist/runtime/shaderRuntime.d.ts +7 -7
- package/dist/runtime/shaderRuntime.d.ts.map +1 -1
- package/dist/runtime/shaderRuntime.js +7 -8
- package/dist/runtime/shaderRuntime.js.map +1 -1
- package/dist/runtime/smartFilterRuntime.d.ts +3 -3
- package/dist/runtime/smartFilterRuntime.d.ts.map +1 -1
- package/dist/runtime/smartFilterRuntime.js.map +1 -1
- package/dist/runtime/strongRef.d.ts +1 -1
- package/dist/runtime/strongRef.js +1 -1
- package/dist/serialization/importCustomBlockDefinition.d.ts +1 -1
- package/dist/serialization/importCustomBlockDefinition.js +8 -9
- package/dist/serialization/importCustomBlockDefinition.js.map +1 -1
- package/dist/serialization/index.d.ts +1 -0
- package/dist/serialization/index.d.ts.map +1 -1
- package/dist/serialization/index.js +3 -0
- package/dist/serialization/index.js.map +1 -1
- package/dist/serialization/serializedBlockDefinition.d.ts +2 -2
- package/dist/serialization/serializedBlockDefinition.d.ts.map +1 -1
- package/dist/serialization/serializedShaderBlockDefinition.d.ts +1 -1
- package/dist/serialization/serializedShaderBlockDefinition.d.ts.map +1 -1
- package/dist/serialization/serializedSmartFilter.d.ts +1 -1
- package/dist/serialization/serializedSmartFilter.d.ts.map +1 -1
- package/dist/serialization/smartFilterDeserializer.d.ts +6 -6
- package/dist/serialization/smartFilterDeserializer.d.ts.map +1 -1
- package/dist/serialization/smartFilterDeserializer.js +14 -12
- package/dist/serialization/smartFilterDeserializer.js.map +1 -1
- package/dist/serialization/smartFilterSerializer.d.ts +2 -2
- package/dist/serialization/smartFilterSerializer.d.ts.map +1 -1
- package/dist/serialization/smartFilterSerializer.js +10 -13
- package/dist/serialization/smartFilterSerializer.js.map +1 -1
- package/dist/serialization/v1/defaultBlockSerializer.d.ts +2 -2
- package/dist/serialization/v1/defaultBlockSerializer.d.ts.map +1 -1
- package/dist/serialization/v1/defaultBlockSerializer.js +3 -1
- package/dist/serialization/v1/defaultBlockSerializer.js.map +1 -1
- package/dist/serialization/v1/index.d.ts +1 -0
- package/dist/serialization/v1/index.d.ts.map +1 -1
- package/dist/serialization/v1/index.js +2 -0
- package/dist/serialization/v1/index.js.map +1 -1
- package/dist/serialization/v1/shaderBlockSerialization.types.d.ts +3 -3
- package/dist/serialization/v1/shaderBlockSerialization.types.d.ts.map +1 -1
- package/dist/serialization/v1/smartFilterSerialization.types.d.ts +5 -2
- package/dist/serialization/v1/smartFilterSerialization.types.d.ts.map +1 -1
- package/dist/smartFilter.d.ts +8 -8
- package/dist/smartFilter.d.ts.map +1 -1
- package/dist/smartFilter.js +6 -7
- package/dist/smartFilter.js.map +1 -1
- package/dist/utils/buildTools/buildShaders.d.ts +3 -2
- package/dist/utils/buildTools/buildShaders.d.ts.map +1 -1
- package/dist/utils/buildTools/buildShaders.js +7 -6
- package/dist/utils/buildTools/buildShaders.js.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoBlock.d.ts +4 -2
- package/dist/utils/buildTools/convertGlslIntoBlock.d.ts.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoBlock.js +136 -141
- package/dist/utils/buildTools/convertGlslIntoBlock.js.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.d.ts +4 -4
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.d.ts.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.js +55 -48
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.js.map +1 -1
- package/dist/utils/buildTools/convertShaders.d.ts +8 -5
- package/dist/utils/buildTools/convertShaders.d.ts.map +1 -1
- package/dist/utils/buildTools/convertShaders.js +38 -14
- package/dist/utils/buildTools/convertShaders.js.map +1 -1
- package/dist/utils/buildTools/shaderConverter.d.ts +4 -4
- package/dist/utils/buildTools/shaderConverter.d.ts.map +1 -1
- package/dist/utils/buildTools/shaderConverter.js +17 -21
- package/dist/utils/buildTools/shaderConverter.js.map +1 -1
- package/dist/utils/buildTools/watchShaders.d.ts +3 -2
- package/dist/utils/buildTools/watchShaders.d.ts.map +1 -1
- package/dist/utils/buildTools/watchShaders.js +10 -8
- package/dist/utils/buildTools/watchShaders.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/renderTargetUtils.d.ts +3 -3
- package/dist/utils/renderTargetUtils.d.ts.map +1 -1
- package/dist/utils/renderTargetUtils.js +4 -4
- package/dist/utils/renderTargetUtils.js.map +1 -1
- package/dist/utils/shaderCodeUtils.d.ts +8 -8
- package/dist/utils/shaderCodeUtils.d.ts.map +1 -1
- package/dist/utils/shaderCodeUtils.js +16 -28
- package/dist/utils/shaderCodeUtils.js.map +1 -1
- package/dist/utils/textureLoaders.d.ts +2 -2
- package/dist/utils/textureLoaders.d.ts.map +1 -1
- package/dist/utils/textureLoaders.js +2 -3
- package/dist/utils/textureLoaders.js.map +1 -1
- package/dist/utils/textureUtils.d.ts +5 -5
- package/dist/utils/textureUtils.d.ts.map +1 -1
- package/dist/utils/textureUtils.js +1 -1
- package/dist/utils/textureUtils.js.map +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.js +2 -2
- package/license.md +21 -21
- package/package.json +14 -9
- package/src/blockFoundation/aggregateBlock.ts +148 -151
- package/src/blockFoundation/baseBlock.ts +339 -364
- package/src/blockFoundation/customAggregateBlock.ts +88 -104
- package/src/blockFoundation/customShaderBlock.ts +312 -326
- package/src/blockFoundation/disableableShaderBlock.ts +91 -100
- package/src/blockFoundation/index.ts +9 -9
- package/src/blockFoundation/inputBlock.deserializer.ts +72 -97
- package/src/blockFoundation/inputBlock.serialization.types.ts +126 -132
- package/src/blockFoundation/inputBlock.serializer.ts +150 -150
- package/src/blockFoundation/inputBlock.ts +181 -192
- package/src/blockFoundation/outputBlock.ts +144 -151
- package/src/blockFoundation/shaderBlock.ts +156 -163
- package/src/blockFoundation/textureOptions.ts +57 -57
- package/src/command/command.ts +59 -59
- package/src/command/commandBuffer.ts +71 -71
- package/src/command/commandBufferDebugger.ts +14 -14
- package/src/command/index.ts +7 -3
- package/src/connection/connectionPoint.ts +205 -214
- package/src/connection/connectionPointCompatibilityState.ts +31 -31
- package/src/connection/connectionPointType.ts +45 -45
- package/src/connection/connectionPointWithDefault.ts +27 -35
- package/src/connection/index.ts +8 -9
- package/src/editorUtils/editableInPropertyPage.ts +106 -106
- package/src/editorUtils/index.ts +3 -1
- package/src/index.ts +16 -15
- package/src/optimization/dependencyGraph.ts +96 -96
- package/src/optimization/index.ts +1 -1
- package/src/optimization/optimizedShaderBlock.ts +131 -134
- package/src/optimization/smartFilterOptimizer.ts +757 -825
- package/src/runtime/index.ts +8 -6
- package/src/runtime/renderTargetGenerator.ts +222 -248
- package/src/runtime/shaderRuntime.ts +174 -173
- package/src/runtime/smartFilterRuntime.ts +112 -112
- package/src/runtime/strongRef.ts +18 -18
- package/src/serialization/importCustomBlockDefinition.ts +86 -86
- package/src/serialization/index.ts +10 -7
- package/src/serialization/serializedBlockDefinition.ts +12 -12
- package/src/serialization/serializedShaderBlockDefinition.ts +7 -7
- package/src/serialization/serializedSmartFilter.ts +6 -6
- package/src/serialization/smartFilterDeserializer.ts +190 -214
- package/src/serialization/smartFilterSerializer.ts +110 -121
- package/src/serialization/v1/defaultBlockSerializer.ts +21 -19
- package/src/serialization/v1/index.ts +4 -2
- package/src/serialization/v1/shaderBlockSerialization.types.ts +85 -85
- package/src/serialization/v1/smartFilterSerialization.types.ts +129 -129
- package/src/smartFilter.ts +255 -260
- package/src/utils/buildTools/buildShaders.ts +14 -13
- package/src/utils/buildTools/convertGlslIntoBlock.ts +370 -385
- package/src/utils/buildTools/convertGlslIntoShaderProgram.ts +173 -172
- package/src/utils/buildTools/convertShaders.ts +65 -43
- package/src/utils/buildTools/recordVersionNumber.js +17 -0
- package/src/utils/buildTools/shaderConverter.ts +466 -478
- package/src/utils/buildTools/watchShaders.ts +44 -42
- package/src/utils/index.ts +4 -2
- package/src/utils/renderTargetUtils.ts +30 -35
- package/src/utils/shaderCodeUtils.ts +192 -207
- package/src/utils/textureLoaders.ts +31 -43
- package/src/utils/textureUtils.ts +28 -32
- package/src/version.ts +2 -2
- package/dist/utils/buildTools/determineVersion.d.ts +0 -36
- package/dist/utils/buildTools/determineVersion.d.ts.map +0 -1
- package/dist/utils/buildTools/determineVersion.js +0 -109
- package/dist/utils/buildTools/determineVersion.js.map +0 -1
- package/dist/utils/buildTools/versionUp.d.ts +0 -2
- package/dist/utils/buildTools/versionUp.d.ts.map +0 -1
- package/dist/utils/buildTools/versionUp.js +0 -53
- package/dist/utils/buildTools/versionUp.js.map +0 -1
- package/src/utils/buildTools/determineVersion.ts +0 -128
- package/src/utils/buildTools/versionUp.ts +0 -61
|
@@ -1,32 +1,28 @@
|
|
|
1
|
-
import type { TextureSize } from "
|
|
2
|
-
import type { OutputTextureOptions } from "../blockFoundation/textureOptions";
|
|
3
|
-
import type { SmartFilter } from "../smartFilter";
|
|
4
|
-
import type { ThinEngine } from "
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Determines the output texture size for a given shader block
|
|
8
|
-
* @param smartFilter - The smart filter to use
|
|
9
|
-
* @param engine - The engine to use
|
|
10
|
-
* @param textureOptions - The texture options to use
|
|
11
|
-
* @returns - The output texture size
|
|
12
|
-
*/
|
|
13
|
-
export function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
outputWidth
|
|
26
|
-
outputHeight
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
width: Math.floor(outputWidth * textureOptions.ratio),
|
|
30
|
-
height: Math.floor(outputHeight * textureOptions.ratio),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
1
|
+
import type { TextureSize } from "core/Materials/Textures/textureCreationOptions.js";
|
|
2
|
+
import type { OutputTextureOptions } from "../blockFoundation/textureOptions.js";
|
|
3
|
+
import type { SmartFilter } from "../smartFilter.js";
|
|
4
|
+
import type { ThinEngine } from "core/Engines/thinEngine.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Determines the output texture size for a given shader block
|
|
8
|
+
* @param smartFilter - The smart filter to use
|
|
9
|
+
* @param engine - The engine to use
|
|
10
|
+
* @param textureOptions - The texture options to use
|
|
11
|
+
* @returns - The output texture size
|
|
12
|
+
*/
|
|
13
|
+
export function GetBlockOutputTextureSize(smartFilter: SmartFilter, engine: ThinEngine, textureOptions: OutputTextureOptions): TextureSize {
|
|
14
|
+
let outputWidth: number;
|
|
15
|
+
let outputHeight: number;
|
|
16
|
+
const renderTargetWrapper = smartFilter.outputBlock.renderTargetWrapper;
|
|
17
|
+
if (renderTargetWrapper) {
|
|
18
|
+
outputWidth = renderTargetWrapper.width;
|
|
19
|
+
outputHeight = renderTargetWrapper.height;
|
|
20
|
+
} else {
|
|
21
|
+
outputWidth = engine.getRenderWidth(true);
|
|
22
|
+
outputHeight = engine.getRenderHeight(true);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
width: Math.floor(outputWidth * textureOptions.ratio),
|
|
26
|
+
height: Math.floor(outputHeight * textureOptions.ratio),
|
|
27
|
+
};
|
|
28
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The version of the SmartFilter core. During publish, this file is overwritten by
|
|
2
|
+
* The version of the SmartFilter core. During publish, this file is overwritten by recordVersionNumber.ts with the same version that is used for the NPM publish.
|
|
3
3
|
*/
|
|
4
|
-
export const SmartFilterCoreVersion = "
|
|
4
|
+
export const SmartFilterCoreVersion = "8.18.0";
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { Nullable } from "@babylonjs/core/types";
|
|
2
|
-
import type { ExecException } from "child_process";
|
|
3
|
-
/**
|
|
4
|
-
* Takes in a semver string (e.g. "0.1.0" or "0.1.0-alpha") and removes any prerelease flag.
|
|
5
|
-
* @param version - The semver string to operate on
|
|
6
|
-
* @returns The version string with the prerelease flag removed
|
|
7
|
-
*/
|
|
8
|
-
export declare function removePrereleaseFlags(version: string): string;
|
|
9
|
-
/**
|
|
10
|
-
* Given the npmVersion, packageJSONVersion, and alpha flag, determines the version to use
|
|
11
|
-
* @param npmVersion - The version from the NPM registry
|
|
12
|
-
* @param packageJSONVersion - The version from the package.json file
|
|
13
|
-
* @param alpha - A flag to indicate if the version should have an alpha prerelease flag
|
|
14
|
-
* @returns The version to use
|
|
15
|
-
*/
|
|
16
|
-
export declare function determineVersion(npmVersion: Nullable<string>, packageJSONVersion: string, alpha: boolean): string;
|
|
17
|
-
/**
|
|
18
|
-
* The supported version types
|
|
19
|
-
*/
|
|
20
|
-
export type VersionType = "preview" | "latest";
|
|
21
|
-
/**
|
|
22
|
-
* Handles error cases and returns the JSON of the package versions
|
|
23
|
-
* @param versionType - The type of version to get
|
|
24
|
-
* @param err - The error object
|
|
25
|
-
* @param stdout - The stdout string
|
|
26
|
-
* @returns The JSON of the package versions
|
|
27
|
-
*/
|
|
28
|
-
export declare function getNpmVersion(versionType: VersionType, err: Nullable<ExecException>, stdout: string): Nullable<string>;
|
|
29
|
-
/**
|
|
30
|
-
* Compares two semver strings, returning -1 if version1 is less than version2, 1 if version1 is greater than version2, and 0 if they are equal
|
|
31
|
-
* @param version1 - The first semver string
|
|
32
|
-
* @param version2 - The second semver string
|
|
33
|
-
* @returns -1 if version1 is less than version2, 1 if version1 is greater than version2, and 0 if they are equal
|
|
34
|
-
*/
|
|
35
|
-
export declare function compareVersions(version1: string, version2: string): number;
|
|
36
|
-
//# sourceMappingURL=determineVersion.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"determineVersion.d.ts","sourceRoot":"","sources":["../../../src/utils/buildTools/determineVersion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AA6BnD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAO7D;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAmBjH;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,aAAa,CACzB,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,QAAQ,CAAC,aAAa,CAAC,EAC5B,MAAM,EAAE,MAAM,GACf,QAAQ,CAAC,MAAM,CAAC,CAWlB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAmB1E"}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Determines if the major and minor versions of two semver strings match
|
|
3
|
-
* @param version1 - The first semver string
|
|
4
|
-
* @param version2 - The second semver string
|
|
5
|
-
* @returns True if the major and minor versions match, false otherwise
|
|
6
|
-
*/
|
|
7
|
-
function majorAndMinorVersionsMatch(version1, version2) {
|
|
8
|
-
const version1split = version1.split(".");
|
|
9
|
-
const version2split = version2.split(".");
|
|
10
|
-
return version1split[0] === version2split[0] && version1split[1] === version2split[1];
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Takes in a semver string (e.g. "0.1.0") and increments the patch version.
|
|
14
|
-
* Note: it does not preserve any prerelease flags in the patch version.
|
|
15
|
-
* @param version - The semver string to operate on
|
|
16
|
-
* @returns The incremented version string
|
|
17
|
-
*/
|
|
18
|
-
function incrementPatchVersion(version) {
|
|
19
|
-
const spl = version.split(".");
|
|
20
|
-
if (spl.length < 3) {
|
|
21
|
-
throw new Error("version string must have at least 3 parts");
|
|
22
|
-
}
|
|
23
|
-
spl[spl.length - 1] = (Number.parseInt(spl[spl.length - 1]) + 1).toString();
|
|
24
|
-
return spl.join(".");
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Takes in a semver string (e.g. "0.1.0" or "0.1.0-alpha") and removes any prerelease flag.
|
|
28
|
-
* @param version - The semver string to operate on
|
|
29
|
-
* @returns The version string with the prerelease flag removed
|
|
30
|
-
*/
|
|
31
|
-
export function removePrereleaseFlags(version) {
|
|
32
|
-
const spl = version.split(".");
|
|
33
|
-
if (spl.length < 3) {
|
|
34
|
-
throw new Error("version string must have at least 3 parts");
|
|
35
|
-
}
|
|
36
|
-
spl[spl.length - 1] = Number.parseInt(spl[spl.length - 1]).toString();
|
|
37
|
-
return spl.join(".");
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Given the npmVersion, packageJSONVersion, and alpha flag, determines the version to use
|
|
41
|
-
* @param npmVersion - The version from the NPM registry
|
|
42
|
-
* @param packageJSONVersion - The version from the package.json file
|
|
43
|
-
* @param alpha - A flag to indicate if the version should have an alpha prerelease flag
|
|
44
|
-
* @returns The version to use
|
|
45
|
-
*/
|
|
46
|
-
export function determineVersion(npmVersion, packageJSONVersion, alpha) {
|
|
47
|
-
packageJSONVersion = removePrereleaseFlags(packageJSONVersion);
|
|
48
|
-
npmVersion = npmVersion === null ? null : removePrereleaseFlags(npmVersion);
|
|
49
|
-
let versionToUse;
|
|
50
|
-
if (npmVersion === null || !majorAndMinorVersionsMatch(npmVersion, packageJSONVersion)) {
|
|
51
|
-
console.log("Major & minor versions do not match: using the current package.json version");
|
|
52
|
-
versionToUse = packageJSONVersion;
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
console.log("Major & minor versions match: using the NPM registry version with an incremented patch version.");
|
|
56
|
-
versionToUse = incrementPatchVersion(npmVersion);
|
|
57
|
-
}
|
|
58
|
-
if (alpha) {
|
|
59
|
-
console.log("Ensuring -alpha prerelease flag is present");
|
|
60
|
-
versionToUse += "-alpha";
|
|
61
|
-
}
|
|
62
|
-
return versionToUse;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Handles error cases and returns the JSON of the package versions
|
|
66
|
-
* @param versionType - The type of version to get
|
|
67
|
-
* @param err - The error object
|
|
68
|
-
* @param stdout - The stdout string
|
|
69
|
-
* @returns The JSON of the package versions
|
|
70
|
-
*/
|
|
71
|
-
export function getNpmVersion(versionType, err, stdout) {
|
|
72
|
-
let npmVersion = null;
|
|
73
|
-
if ((err === null || err === void 0 ? void 0 : err.message) && err.message.indexOf("E404") !== -1) {
|
|
74
|
-
console.warn(`NPM registry does not have any ${versionType} version`);
|
|
75
|
-
}
|
|
76
|
-
else if (err) {
|
|
77
|
-
console.error(err);
|
|
78
|
-
throw err;
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
npmVersion = stdout;
|
|
82
|
-
}
|
|
83
|
-
return npmVersion;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Compares two semver strings, returning -1 if version1 is less than version2, 1 if version1 is greater than version2, and 0 if they are equal
|
|
87
|
-
* @param version1 - The first semver string
|
|
88
|
-
* @param version2 - The second semver string
|
|
89
|
-
* @returns -1 if version1 is less than version2, 1 if version1 is greater than version2, and 0 if they are equal
|
|
90
|
-
*/
|
|
91
|
-
export function compareVersions(version1, version2) {
|
|
92
|
-
const version1split = removePrereleaseFlags(version1).split(".");
|
|
93
|
-
const version2split = removePrereleaseFlags(version2).split(".");
|
|
94
|
-
if (version1split.length !== 3 || version2split.length !== 3) {
|
|
95
|
-
throw new Error("version strings must have 3 parts");
|
|
96
|
-
}
|
|
97
|
-
for (let i = 0; i < 3; i++) {
|
|
98
|
-
const v1 = Number.parseInt(version1split[i]);
|
|
99
|
-
const v2 = Number.parseInt(version2split[i]);
|
|
100
|
-
if (v1 < v2) {
|
|
101
|
-
return -1;
|
|
102
|
-
}
|
|
103
|
-
else if (v1 > v2) {
|
|
104
|
-
return 1;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return 0;
|
|
108
|
-
}
|
|
109
|
-
//# sourceMappingURL=determineVersion.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"determineVersion.js","sourceRoot":"","sources":["../../../src/utils/buildTools/determineVersion.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,SAAS,0BAA0B,CAAC,QAAgB,EAAE,QAAgB;IAClE,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1C,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,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B;IAC9D,MAAM,aAAa,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjE,MAAM,aAAa,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEjE,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACzB,MAAM,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAE,CAAC,CAAC;QAC9C,MAAM,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAE,CAAC,CAAC;QAE9C,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;YACV,OAAO,CAAC,CAAC,CAAC;QACd,CAAC;aAAM,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;YACjB,OAAO,CAAC,CAAC;QACb,CAAC;IACL,CAAC;IACD,OAAO,CAAC,CAAC;AACb,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"versionUp.d.ts","sourceRoot":"","sources":["../../../src/utils/buildTools/versionUp.ts"],"names":[],"mappings":""}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import * as fs from "fs";
|
|
3
|
-
import { exec } from "child_process";
|
|
4
|
-
import { compareVersions, determineVersion, getNpmVersion } from "./determineVersion.js";
|
|
5
|
-
const alpha = process.argv.includes("--alpha");
|
|
6
|
-
const packageText = fs.readFileSync("package.json");
|
|
7
|
-
const packageJSON = JSON.parse(packageText.toString());
|
|
8
|
-
const packageName = packageJSON.name;
|
|
9
|
-
console.log("Processing package:", packageName);
|
|
10
|
-
console.log("Alpha flag:", alpha);
|
|
11
|
-
console.log("Current package.json version:", packageJSON.version);
|
|
12
|
-
/**
|
|
13
|
-
* Queries the NPM registry for the specified version type
|
|
14
|
-
* @param versionType - The type of version to query
|
|
15
|
-
* @param callback - The callback to call with the NPM version
|
|
16
|
-
*/
|
|
17
|
-
function queryNpmFeed(versionType, callback) {
|
|
18
|
-
exec(`npm view ${packageName} dist-tags.${versionType}`, (err, stdout) => {
|
|
19
|
-
let npmVersion = getNpmVersion(versionType, err, stdout);
|
|
20
|
-
if (npmVersion !== null) {
|
|
21
|
-
npmVersion = npmVersion.trim();
|
|
22
|
-
console.log(`NPM Registry ${versionType} version:`, npmVersion);
|
|
23
|
-
}
|
|
24
|
-
callback(npmVersion);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
queryNpmFeed("preview", (npmPreviewVersion) => {
|
|
28
|
-
queryNpmFeed("latest", (npmLatestVersion) => {
|
|
29
|
-
let highestNpmVersion = npmLatestVersion;
|
|
30
|
-
if (npmPreviewVersion && (!highestNpmVersion || compareVersions(npmPreviewVersion, highestNpmVersion) === 1)) {
|
|
31
|
-
highestNpmVersion = npmPreviewVersion;
|
|
32
|
-
}
|
|
33
|
-
console.log("Highest NPM Registry version:", highestNpmVersion);
|
|
34
|
-
const versionToUse = determineVersion(highestNpmVersion, packageJSON.version, alpha);
|
|
35
|
-
console.log("Version to use:", versionToUse);
|
|
36
|
-
// Update package.json if needed
|
|
37
|
-
if (packageJSON.version !== versionToUse) {
|
|
38
|
-
packageJSON.version = versionToUse;
|
|
39
|
-
fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 4));
|
|
40
|
-
console.log("Version updated in package.json");
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
console.log("No need to update package.json");
|
|
44
|
-
}
|
|
45
|
-
// Write out to version.ts
|
|
46
|
-
const versionTsText = `/**
|
|
47
|
-
* The version of the SmartFilter core. During publish, this file is overwritten by versionUp.ts with the same version that is used for the NPM publish.
|
|
48
|
-
*/
|
|
49
|
-
export const SmartFilterCoreVersion = "${versionToUse}";\n`;
|
|
50
|
-
fs.writeFileSync("src/version.ts", versionTsText);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
//# sourceMappingURL=versionUp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"versionUp.js","sourceRoot":"","sources":["../../../src/utils/buildTools/versionUp.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,IAAI,EAAsB,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAoB,MAAM,uBAAuB,CAAC;AAG3G,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;AACpD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;AAEvD,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC;AACrC,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;AAChD,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AAClC,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;AAElE;;;;GAIG;AACH,SAAS,YAAY,CAAC,WAAwB,EAAE,QAAgD;IAC5F,IAAI,CAAC,YAAY,WAAW,cAAc,WAAW,EAAE,EAAE,CAAC,GAA4B,EAAE,MAAM,EAAE,EAAE;QAC9F,IAAI,UAAU,GAAG,aAAa,CAAC,WAAW,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QACzD,IAAI,UAAU,KAAK,IAAI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,gBAAgB,EAAE,aAAa,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import type { Nullable } from "@babylonjs/core/types";
|
|
3
|
-
import type { ExecException } from "child_process";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Determines if the major and minor versions of two semver strings match
|
|
7
|
-
* @param version1 - The first semver string
|
|
8
|
-
* @param version2 - The second semver string
|
|
9
|
-
* @returns True if the major and minor versions match, false otherwise
|
|
10
|
-
*/
|
|
11
|
-
function majorAndMinorVersionsMatch(version1: string, version2: string): boolean {
|
|
12
|
-
const version1split = version1.split(".");
|
|
13
|
-
const version2split = version2.split(".");
|
|
14
|
-
return version1split[0] === version2split[0] && version1split[1] === version2split[1];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Takes in a semver string (e.g. "0.1.0") and increments the patch version.
|
|
19
|
-
* Note: it does not preserve any prerelease flags in the patch version.
|
|
20
|
-
* @param version - The semver string to operate on
|
|
21
|
-
* @returns The incremented version string
|
|
22
|
-
*/
|
|
23
|
-
function incrementPatchVersion(version: string): string {
|
|
24
|
-
const spl = version.split(".");
|
|
25
|
-
if (spl.length < 3) {
|
|
26
|
-
throw new Error("version string must have at least 3 parts");
|
|
27
|
-
}
|
|
28
|
-
spl[spl.length - 1] = (Number.parseInt(spl[spl.length - 1]!) + 1).toString();
|
|
29
|
-
return spl.join(".");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Takes in a semver string (e.g. "0.1.0" or "0.1.0-alpha") and removes any prerelease flag.
|
|
34
|
-
* @param version - The semver string to operate on
|
|
35
|
-
* @returns The version string with the prerelease flag removed
|
|
36
|
-
*/
|
|
37
|
-
export function removePrereleaseFlags(version: string): string {
|
|
38
|
-
const spl = version.split(".");
|
|
39
|
-
if (spl.length < 3) {
|
|
40
|
-
throw new Error("version string must have at least 3 parts");
|
|
41
|
-
}
|
|
42
|
-
spl[spl.length - 1] = Number.parseInt(spl[spl.length - 1]!).toString();
|
|
43
|
-
return spl.join(".");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Given the npmVersion, packageJSONVersion, and alpha flag, determines the version to use
|
|
48
|
-
* @param npmVersion - The version from the NPM registry
|
|
49
|
-
* @param packageJSONVersion - The version from the package.json file
|
|
50
|
-
* @param alpha - A flag to indicate if the version should have an alpha prerelease flag
|
|
51
|
-
* @returns The version to use
|
|
52
|
-
*/
|
|
53
|
-
export function determineVersion(npmVersion: Nullable<string>, packageJSONVersion: string, alpha: boolean): string {
|
|
54
|
-
packageJSONVersion = removePrereleaseFlags(packageJSONVersion);
|
|
55
|
-
npmVersion = npmVersion === null ? null : removePrereleaseFlags(npmVersion);
|
|
56
|
-
|
|
57
|
-
let versionToUse;
|
|
58
|
-
if (npmVersion === null || !majorAndMinorVersionsMatch(npmVersion, packageJSONVersion)) {
|
|
59
|
-
console.log("Major & minor versions do not match: using the current package.json version");
|
|
60
|
-
versionToUse = packageJSONVersion;
|
|
61
|
-
} else {
|
|
62
|
-
console.log("Major & minor versions match: using the NPM registry version with an incremented patch version.");
|
|
63
|
-
versionToUse = incrementPatchVersion(npmVersion);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (alpha) {
|
|
67
|
-
console.log("Ensuring -alpha prerelease flag is present");
|
|
68
|
-
versionToUse += "-alpha";
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return versionToUse;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* The supported version types
|
|
76
|
-
*/
|
|
77
|
-
export type VersionType = "preview" | "latest";
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Handles error cases and returns the JSON of the package versions
|
|
81
|
-
* @param versionType - The type of version to get
|
|
82
|
-
* @param err - The error object
|
|
83
|
-
* @param stdout - The stdout string
|
|
84
|
-
* @returns The JSON of the package versions
|
|
85
|
-
*/
|
|
86
|
-
export function getNpmVersion(
|
|
87
|
-
versionType: VersionType,
|
|
88
|
-
err: Nullable<ExecException>,
|
|
89
|
-
stdout: string
|
|
90
|
-
): Nullable<string> {
|
|
91
|
-
let npmVersion = null;
|
|
92
|
-
if (err?.message && err.message.indexOf("E404") !== -1) {
|
|
93
|
-
console.warn(`NPM registry does not have any ${versionType} version`);
|
|
94
|
-
} else if (err) {
|
|
95
|
-
console.error(err);
|
|
96
|
-
throw err;
|
|
97
|
-
} else {
|
|
98
|
-
npmVersion = stdout;
|
|
99
|
-
}
|
|
100
|
-
return npmVersion;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Compares two semver strings, returning -1 if version1 is less than version2, 1 if version1 is greater than version2, and 0 if they are equal
|
|
105
|
-
* @param version1 - The first semver string
|
|
106
|
-
* @param version2 - The second semver string
|
|
107
|
-
* @returns -1 if version1 is less than version2, 1 if version1 is greater than version2, and 0 if they are equal
|
|
108
|
-
*/
|
|
109
|
-
export function compareVersions(version1: string, version2: string): number {
|
|
110
|
-
const version1split = removePrereleaseFlags(version1).split(".");
|
|
111
|
-
const version2split = removePrereleaseFlags(version2).split(".");
|
|
112
|
-
|
|
113
|
-
if (version1split.length !== 3 || version2split.length !== 3) {
|
|
114
|
-
throw new Error("version strings must have 3 parts");
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
for (let i = 0; i < 3; i++) {
|
|
118
|
-
const v1 = Number.parseInt(version1split[i]!);
|
|
119
|
-
const v2 = Number.parseInt(version2split[i]!);
|
|
120
|
-
|
|
121
|
-
if (v1 < v2) {
|
|
122
|
-
return -1;
|
|
123
|
-
} else if (v1 > v2) {
|
|
124
|
-
return 1;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return 0;
|
|
128
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import * as fs from "fs";
|
|
3
|
-
import { exec, type ExecException } from "child_process";
|
|
4
|
-
import { compareVersions, determineVersion, getNpmVersion, type VersionType } from "./determineVersion.js";
|
|
5
|
-
import type { Nullable } from "@babylonjs/core/types.js";
|
|
6
|
-
|
|
7
|
-
const alpha = process.argv.includes("--alpha");
|
|
8
|
-
const packageText = fs.readFileSync("package.json");
|
|
9
|
-
const packageJSON = JSON.parse(packageText.toString());
|
|
10
|
-
|
|
11
|
-
const packageName = packageJSON.name;
|
|
12
|
-
console.log("Processing package:", packageName);
|
|
13
|
-
console.log("Alpha flag:", alpha);
|
|
14
|
-
console.log("Current package.json version:", packageJSON.version);
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Queries the NPM registry for the specified version type
|
|
18
|
-
* @param versionType - The type of version to query
|
|
19
|
-
* @param callback - The callback to call with the NPM version
|
|
20
|
-
*/
|
|
21
|
-
function queryNpmFeed(versionType: VersionType, callback: (npmVersion: Nullable<string>) => void) {
|
|
22
|
-
exec(`npm view ${packageName} dist-tags.${versionType}`, (err: Nullable<ExecException>, stdout) => {
|
|
23
|
-
let npmVersion = getNpmVersion(versionType, err, stdout);
|
|
24
|
-
if (npmVersion !== null) {
|
|
25
|
-
npmVersion = npmVersion.trim();
|
|
26
|
-
console.log(`NPM Registry ${versionType} version:`, npmVersion);
|
|
27
|
-
}
|
|
28
|
-
callback(npmVersion);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
queryNpmFeed("preview", (npmPreviewVersion) => {
|
|
33
|
-
queryNpmFeed("latest", (npmLatestVersion) => {
|
|
34
|
-
let highestNpmVersion: Nullable<string> = npmLatestVersion;
|
|
35
|
-
if (npmPreviewVersion && (!highestNpmVersion || compareVersions(npmPreviewVersion, highestNpmVersion) === 1)) {
|
|
36
|
-
highestNpmVersion = npmPreviewVersion;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
console.log("Highest NPM Registry version:", highestNpmVersion);
|
|
40
|
-
|
|
41
|
-
const versionToUse = determineVersion(highestNpmVersion, packageJSON.version, alpha);
|
|
42
|
-
|
|
43
|
-
console.log("Version to use:", versionToUse);
|
|
44
|
-
|
|
45
|
-
// Update package.json if needed
|
|
46
|
-
if (packageJSON.version !== versionToUse) {
|
|
47
|
-
packageJSON.version = versionToUse;
|
|
48
|
-
fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 4));
|
|
49
|
-
console.log("Version updated in package.json");
|
|
50
|
-
} else {
|
|
51
|
-
console.log("No need to update package.json");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Write out to version.ts
|
|
55
|
-
const versionTsText = `/**
|
|
56
|
-
* The version of the SmartFilter core. During publish, this file is overwritten by versionUp.ts with the same version that is used for the NPM publish.
|
|
57
|
-
*/
|
|
58
|
-
export const SmartFilterCoreVersion = "${versionToUse}";\n`;
|
|
59
|
-
fs.writeFileSync("src/version.ts", versionTsText);
|
|
60
|
-
});
|
|
61
|
-
});
|