Skip to content

Commit 6ebad5f

Browse files
committed
Note about standalone API
Signed-off-by: worksofliam <[email protected]>
1 parent 6cad595 commit 6ebad5f

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

src/content/docs/dev/api.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,54 @@ export function loadBase(): CodeForIBMi|undefined {
6565
export function getInstance(): Instance|undefined {
6666
return (baseExtension && baseExtension.isActive && baseExtension.exports ? baseExtension.exports.instance : undefined);
6767
}
68-
```
68+
```
69+
70+
## Outside of VS Code
71+
72+
**This is not production ready**.
73+
74+
<details>
75+
<summary>Click to expand</summary>
76+
77+
On the main branch of vscode-ibmi, the IBM i API is written so it is can be portable and used outside of the VS Code namespace (this is how the vitest tests work). Until we publish the API as a standalone package, you will need to manually import the API.
78+
79+
After using `npm i github:codefori/vscode-ibmi`, you will need to cleanup/remove everything but the `src/api` directory.
80+
81+
```ts
82+
//#webpack.config.js
83+
84+
function prepareIbmiApi() {
85+
const ibmiApi = path.join(__dirname, `node_modules`, `vscode-ibmi`, `src`, `api`);
86+
const ibmiPackage = path.join(__dirname, `node_modules`, `vscode-ibmi`, `src`);
87+
88+
const checkDirectory = (dir) => {
89+
if (fs.existsSync(dir)) {
90+
const files = fs.readdirSync(dir);
91+
files.forEach(file => {
92+
const filePath = path.join(dir, file);
93+
const stat = fs.lstatSync(filePath);
94+
const canDelete = !ibmiApi.startsWith(filePath) && !filePath.startsWith(ibmiApi);
95+
if (stat.isDirectory()) {
96+
// If the directory is not the api directory, delete it
97+
if (canDelete) {
98+
fs.rmdirSync(filePath, { recursive: true });
99+
// console.log(`Deleted directory: ${filePath}`);
100+
} else {
101+
checkDirectory(filePath);
102+
}
103+
} else if (stat.isFile()) {
104+
if (canDelete) {
105+
fs.unlinkSync(filePath);
106+
// console.log(`Deleted file: ${filePath}`);
107+
}
108+
}
109+
});
110+
}
111+
}
112+
113+
checkDirectory(ibmiPackage);
114+
}
115+
```
116+
117+
You will also need to enable `allowTsInNodeModules: true` with `ts-loader` in webpack.
118+
</details>

0 commit comments

Comments
 (0)