Fix bin/publish: copy docs.dist from project root

Fix bin/publish: use correct .env path for rspade_system
Fix bin/publish script: prevent grep exit code 1 from terminating script

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-10-21 02:08:33 +00:00
commit f6fac6c4bc
79758 changed files with 10547827 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Joachim Viide
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,92 @@
# babel-plugin-transform-replace-expressions [![CircleCI](https://circleci.com/gh/jviide/babel-plugin-transform-replace-expressions.svg?style=shield)](https://circleci.com/gh/jviide/babel-plugin-transform-replace-expressions) [![npm](https://img.shields.io/npm/v/babel-plugin-transform-replace-expressions.svg)](https://www.npmjs.com/package/babel-plugin-transform-replace-expressions)
Replace JavaScript expressions with other expressions.
## Installation
```
$ yarn add --dev babel-plugin-transform-replace-expressions
```
## Example
Input file:
```js
const env = process.env.NODE_ENV;
typeof Hello === "number";
```
`.babelrc`:
```json
{
"plugins": [
[
"babel-plugin-transform-replace-expressions",
{
"replace": {
"process.env.NODE_ENV": "\"production\"",
"typeof Hello": "42"
}
}
]
]
}
```
Output:
```js
const env = "production";
42 === "number";
```
## Conflict resolution
A conflict happens when two replacements have the same Babel [abstract syntax tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree) representation. For example expressions `typeof A` and `typeof (A)` are formatted differently but have the same AST representation as far as the plugin is concerned. In those situations the default is to raise an error, and can be overwritten by setting the option `allowConflictingReplacements` to `true`.
You can also always give the replacements as an array of key-value pairs. When `allowConflictingReplacements` is set to `true` the _last_ conflicting replacement gets selected.
```js
{
"plugins": [
[
"babel-plugin-transform-replace-expressions",
{
"replace": [
["typeof A", "B"],
["typeof (A)", "C"]
],
"allowConflictingReplacements": true
}
]
]
}
```
## Notes
* Replacements are only applied to expressions. Therefore replacing `DEBUG` with `false` in `const DEBUG = true` does nothing, but for `if (DEBUG) {}` the result is `if (false) {}`.
* Only *full* expressions count. You can't replace `env` in `process.env.NODE_ENV`, you have to replace `process.env`, which is a proper expression in Babel AST.
* A replacement is only applied when the result is valid JavaScript. For example replacing `a` with `2` in the following code:
```js
a = 1;
b = a;
```
yields
```js
a = 1;
b = 2;
```
## License
This plugin is licensed under the MIT license. See [LICENSE](./LICENSE).

View File

@@ -0,0 +1,81 @@
const { parseExpression } = require("@babel/parser");
module.exports = function({ types: t }, options = {}) {
const replace = options.replace || {};
const allowConflictingReplacements = !!options.allowConflictingReplacements;
function asArray(obj) {
if (Array.isArray(obj)) {
return obj;
}
return Object.keys(obj).map(key => [key, obj[key]]);
}
const types = new Map();
asArray(replace).forEach(([key, value]) => {
const kNode = parseExpression(key);
const vNode = parseExpression(value);
const candidates = types.get(kNode.type) || [];
candidates.push({ key: kNode, value: vNode, originalKey: key });
types.set(kNode.type, candidates);
for (let i = 0; i < candidates.length - 1; i++) {
if (!t.isNodesEquivalent(candidates[i].key, kNode)) {
continue;
}
if (allowConflictingReplacements) {
candidates[i] = candidates.pop();
break;
}
throw new Error(
`Expressions ${JSON.stringify(
candidates[i].originalKey
)} and ${JSON.stringify(key)} conflict`
);
}
});
const values = new Set();
types.forEach(candidates => {
candidates.forEach(candidate => {
values.add(candidate.value);
});
});
return {
name: "transform-replace-expressions",
visitor: {
Expression(path) {
if (values.has(path.node)) {
path.skip();
return;
}
const candidates = types.get(path.node.type);
if (!candidates) {
return;
}
for (const { key, value } of candidates) {
if (t.isNodesEquivalent(key, path.node)) {
try {
t.validate(path.parent, path.key, value);
} catch (err) {
if (!(err instanceof TypeError)) {
throw err;
}
path.skip();
return;
}
path.replaceWith(value);
return;
}
}
}
}
};
};

View File

@@ -0,0 +1 @@
../../../@babel/parser/bin/babel-parser.js