You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-07-30 04:23:07 +03:00
Add syntax & type check for Node.js example on CI (#4410)
* Add syntax & type check for Node.js example on CI Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org> * Fix quotes --------- Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org> Co-authored-by: Florian Duros <florianduros@element.io>
This commit is contained in:
35
.github/workflows/static_analysis.yml
vendored
35
.github/workflows/static_analysis.yml
vendored
@ -44,6 +44,41 @@ jobs:
|
|||||||
- name: Run Linter
|
- name: Run Linter
|
||||||
run: "yarn run lint:js"
|
run: "yarn run lint:js"
|
||||||
|
|
||||||
|
node_example_lint:
|
||||||
|
name: "Node.js example"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
cache: "yarn"
|
||||||
|
node-version-file: package.json
|
||||||
|
|
||||||
|
- name: Install Deps
|
||||||
|
run: "yarn install"
|
||||||
|
|
||||||
|
- name: Build Types
|
||||||
|
run: "yarn build:types"
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
cache: "npm"
|
||||||
|
node-version-file: "examples/node/package.json"
|
||||||
|
# cache-dependency-path: '**/package-lock.json'
|
||||||
|
|
||||||
|
- name: Install Example Deps
|
||||||
|
run: "npm install"
|
||||||
|
working-directory: "examples/node"
|
||||||
|
|
||||||
|
- name: Check Syntax
|
||||||
|
run: "node --check app.js"
|
||||||
|
working-directory: "examples/node"
|
||||||
|
|
||||||
|
- name: Typecheck
|
||||||
|
run: "npx tsc"
|
||||||
|
working-directory: "examples/node"
|
||||||
|
|
||||||
workflow_lint:
|
workflow_lint:
|
||||||
name: "Workflow Lint"
|
name: "Workflow Lint"
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
|
@ -94,20 +94,14 @@ rl.on("line", function (line) {
|
|||||||
);
|
);
|
||||||
} else if (line.indexOf("/file ") === 0) {
|
} else if (line.indexOf("/file ") === 0) {
|
||||||
var filename = line.split(" ")[1].trim();
|
var filename = line.split(" ")[1].trim();
|
||||||
var stream = fs.createReadStream(filename);
|
let buffer = fs.readFileSync("./your_file_name");
|
||||||
matrixClient
|
matrixClient.uploadContent(new Blob([buffer])).then(function (response) {
|
||||||
.uploadContent({
|
matrixClient.sendMessage(viewingRoom.roomId, {
|
||||||
stream: stream,
|
msgtype: MsgType.File,
|
||||||
name: filename,
|
body: filename,
|
||||||
})
|
url: response.content_uri,
|
||||||
.then(function (url) {
|
|
||||||
var content = {
|
|
||||||
msgtype: MsgType.File,
|
|
||||||
body: filename,
|
|
||||||
url: JSON.parse(url).content_uri,
|
|
||||||
};
|
|
||||||
matrixClient.sendMessage(viewingRoom.roomId, content);
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
matrixClient.sendTextMessage(viewingRoom.roomId, line).finally(function () {
|
matrixClient.sendTextMessage(viewingRoom.roomId, line).finally(function () {
|
||||||
printMessages();
|
printMessages();
|
||||||
@ -167,7 +161,7 @@ matrixClient.on(RoomEvent.Timeline, function (event, room, toStartOfTimeline) {
|
|||||||
if (toStartOfTimeline) {
|
if (toStartOfTimeline) {
|
||||||
return; // don't print paginated results
|
return; // don't print paginated results
|
||||||
}
|
}
|
||||||
if (!viewingRoom || viewingRoom.roomId !== room.roomId) {
|
if (!viewingRoom || viewingRoom.roomId !== room?.roomId) {
|
||||||
return; // not viewing a room or viewing the wrong room.
|
return; // not viewing a room or viewing the wrong room.
|
||||||
}
|
}
|
||||||
printLine(event);
|
printLine(event);
|
||||||
@ -386,7 +380,7 @@ function print(str, formatter) {
|
|||||||
}
|
}
|
||||||
console.log.apply(console.log, newArgs);
|
console.log.apply(console.log, newArgs);
|
||||||
} else {
|
} else {
|
||||||
console.log.apply(console.log, arguments);
|
console.log.apply(console.log, [...arguments]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,5 +9,12 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cli-color": "^1.0.0",
|
"cli-color": "^1.0.0",
|
||||||
"matrix-js-sdk": "^34.5.0"
|
"matrix-js-sdk": "^34.5.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/cli-color": "^2.0.6",
|
||||||
|
"typescript": "^5.6.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
examples/node/tsconfig.json
Normal file
14
examples/node/tsconfig.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es2022",
|
||||||
|
"module": "commonjs",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"noEmit": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"allowJs": true,
|
||||||
|
"checkJs": true,
|
||||||
|
"strict": true
|
||||||
|
},
|
||||||
|
"include": ["app.js"]
|
||||||
|
}
|
Reference in New Issue
Block a user