-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
634 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
|
||
node_modules | ||
dist | ||
dist.* | ||
package-lock.json | ||
.DS_Store | ||
*.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Vendor library | ||
|
||
This script vendors the following library: | ||
https://github.com/segmentio/tsub-js | ||
|
||
Usage for updating tsub: | ||
- update tsub to new version (tsub should be a _dev dependency_) | ||
- run `yarn vendor` from package root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const fs = require('node:fs') | ||
const path = require('node:path') | ||
|
||
function prependToFile(filePath, content) { | ||
const fileContent = fs.readFileSync(filePath, 'utf8') | ||
fs.writeFileSync(filePath, content + fileContent) | ||
} | ||
|
||
function createTSFromJSLib(inputFilePath, outputDir, { libraryName }) { | ||
const fileName = path.basename(inputFilePath, '.js') + '.ts' | ||
const outputFilePath = path.join(outputDir, fileName) | ||
const libVersion = require(`${libraryName}/package.json`).version | ||
const tsContent = [ | ||
'// @ts-nocheck', | ||
'// prettier-ignore', | ||
'/* eslint-disable */', | ||
`// ${libraryName} ${libVersion} - GENERATED DO NOT MODIFY`, | ||
'\n', | ||
].join('\n') | ||
fs.renameSync(inputFilePath, outputFilePath) | ||
prependToFile(outputFilePath, tsContent) | ||
console.log( | ||
`\n Built ${libraryName} ${libVersion} -> output ${outputFilePath}` | ||
) | ||
return { outputFilePath } | ||
} | ||
|
||
module.exports = { | ||
prependToFile, | ||
createTSFromJSLib, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* This file: | ||
* - uses webpack to build tsub.js | ||
* - converts tsub.js to tsub.ts, appends comments, and moves it into the source directory | ||
*/ | ||
const { execSync } = require('node:child_process') | ||
const path = require('node:path') | ||
|
||
const { createTSFromJSLib } = require('./helpers') | ||
const configPath = 'scripts/vendor/webpack.config.vendor.js' | ||
|
||
execSync(`yarn webpack --config ${configPath}`, { stdio: 'inherit' }) | ||
|
||
const tsubInputBundlePath = path.join(__dirname, 'dist.vendor', 'tsub.js') | ||
const tsubOutputVendorDir = 'src/vendor/tsub' | ||
createTSFromJSLib(tsubInputBundlePath, tsubOutputVendorDir, { | ||
libraryName: '@segment/tsub', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const path = require('node:path') | ||
|
||
/** @type { import('webpack').Configuration } */ | ||
module.exports = { | ||
entry: require.resolve('@segment/tsub'), | ||
output: { | ||
path: path.resolve(__dirname, 'dist.vendor'), // Output directory | ||
filename: 'tsub.js', | ||
library: { | ||
type: 'umd', | ||
}, | ||
}, | ||
resolve: { | ||
extensions: ['.js'], // Resolve these extensions | ||
}, | ||
mode: 'production', // Use production mode for minification, etc. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2018 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2021 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2022 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export interface Rule { | ||
scope: string | ||
target_type: string | ||
matchers: Matcher[] | ||
transformers: Transformer[][] | ||
destinationName?: string | ||
} | ||
export interface Matcher { | ||
type: string | ||
ir: string | ||
} | ||
export interface Transformer { | ||
type: string | ||
config?: any | ||
} | ||
export interface Store { | ||
new (rules?: Rule[]): this | ||
getRulesByDestinationName(destinationName: string): Rule[] | ||
} |
Oops, something went wrong.