Skip to content

Commit 0830906

Browse files
wei-liu-sfclavery
andauthored
@W-21111039: Spike B2C VS Extensions (#124)
* B2C DX VS extension * webview support of webdav commands * support webdav mkdir and rm * W-21111039: B2C DX VS Extension * get the package installation work * support generate pd metadata * support both metadata generation and deploy cartridge * support webdav file preview * support webdav file preview * refactor: clean up VS Code extension build pipeline and SDK imports (#132) * refactor: clean up VS Code extension build pipeline and SDK imports Rationalize the build scripts, remove dead code, and use the correct SDK public API for non-CLI consumers. * wire SDK logger to VS Code output channel Configure the SDK's pino logger at activation time to write to the B2C DX output panel. SDK diagnostic output (WebDAV requests, config resolution, auth flows, deploy progress) is now visible in VS Code. SDK fix: wrap minimal LogDestination in a Node.js Writable before passing to pino-pretty so consumers only need write(). This fix should be incorporated into the SDK independently of the VS extension spike. * adds second launch config for watch mode * remove unncesssary typescript external * add publisher info * fix the publisher * support SLAS client generation and SCAPI execution * added SqrTT.prophet to recommendations --------- Co-authored-by: Charles Lavery <clavery@salesforce.com>
1 parent 4ca6257 commit 0830906

24 files changed

+4650
-142
lines changed

packages/b2c-tooling-sdk/src/logging/logger.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
* Logger using pino with pretty printing by default.
88
*/
99

10+
import {Writable} from 'node:stream';
1011
import pino from 'pino';
1112
import pretty from 'pino-pretty';
12-
import type {Logger, LoggerOptions} from './types.js';
13+
import type {LogDestination, Logger, LoggerOptions} from './types.js';
1314

1415
const REDACT_FIELDS = [
1516
'password',
@@ -61,6 +62,17 @@ function censor(value: unknown, path: string[]): string {
6162
return 'REDACTED';
6263
}
6364

65+
/** Wrap a minimal LogDestination in a Node.js Writable so pino-pretty's transport pipeline works. */
66+
function toWritable(dest: LogDestination): Writable {
67+
if (dest instanceof Writable) return dest;
68+
return new Writable({
69+
write(chunk: Buffer, _encoding: BufferEncoding, callback: (error?: Error | null) => void) {
70+
dest.write(chunk);
71+
callback();
72+
},
73+
});
74+
}
75+
6476
let globalLogger: Logger | null = null;
6577
let globalOptions: LoggerOptions = {level: 'silent'};
6678

@@ -91,7 +103,7 @@ function createPinoLogger(options: LoggerOptions): Logger {
91103
}
92104
const isVerbose = level === 'debug' || level === 'trace';
93105
const prettyStream = pretty({
94-
destination: options.destination,
106+
destination: toWritable(options.destination),
95107
sync: true,
96108
colorize,
97109
ignore: 'pid,hostname' + (isVerbose ? '' : ',time'),
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
out
2+
dist
3+
node_modules
4+
.vscode-test/
5+
.vsce-stage/
6+
*.vsix
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { defineConfig } from '@vscode/test-cli';
2+
3+
export default defineConfig({
4+
files: 'out/test/**/*.test.js',
5+
});
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"dbaeumer.vscode-eslint",
6+
"ms-vscode.extension-test-runner",
7+
"SqrTT.prophet"
8+
]
9+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// A launch configuration that compiles the extension and then opens it inside a new window
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
{
6+
"version": "0.2.0",
7+
"configurations": [
8+
{
9+
"name": "Run Extension",
10+
"type": "extensionHost",
11+
"request": "launch",
12+
"args": [
13+
"--extensionDevelopmentPath=${workspaceFolder}"
14+
],
15+
"outFiles": [
16+
"${workspaceFolder}/dist/**/*.js"
17+
],
18+
"preLaunchTask": "build extension"
19+
},
20+
{
21+
"name": "Run Extension (Dev)",
22+
"type": "extensionHost",
23+
"request": "launch",
24+
"args": [
25+
"--extensionDevelopmentPath=${workspaceFolder}"
26+
],
27+
"outFiles": [
28+
"${workspaceFolder}/dist/**/*.js"
29+
]
30+
}
31+
]
32+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Place your settings in this file to overwrite default and user settings.
2+
{
3+
"files.exclude": {
4+
"out": false // set this to true to hide the "out" folder with the compiled JS files
5+
},
6+
"search.exclude": {
7+
"out": true // set this to false to include "out" folder in search results
8+
},
9+
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10+
"typescript.tsc.autoDetect": "off"
11+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// See https://go.microsoft.com/fwlink/?LinkId=733558
2+
// for the documentation about the tasks.json format
3+
{
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"type": "shell",
8+
"label": "build extension",
9+
"command": "pnpm run build",
10+
"options": { "cwd": "${workspaceFolder}" },
11+
"problemMatcher": [],
12+
"group": { "kind": "build", "isDefault": true }
13+
},
14+
{
15+
"type": "shell",
16+
"label": "watch extension",
17+
"command": "pnpm run watch",
18+
"options": { "cwd": "${workspaceFolder}" },
19+
"problemMatcher": [],
20+
"isBackground": true,
21+
"presentation": { "reveal": "never" }
22+
}
23+
]
24+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.vscode/**
2+
.vscode-test/**
3+
src/**
4+
!src/webview.html
5+
!src/webdav.html
6+
!src/storefront-next-cartridge.html
7+
!src/scapi-explorer.html
8+
out/**
9+
**/node_modules/**
10+
11+
!src/template/**
12+
.gitignore
13+
**/tsconfig.json
14+
**/eslint.config.mjs
15+
**/*.map
16+
**/*.ts
17+
**/.vscode-test.*
18+
**/.pnpm-store/**
19+
**/.turbo/**
20+
packages/**
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.vscode/**
2+
.vscode-test/**
3+
src/**
4+
!src/webview.html
5+
!src/webdav.html
6+
!src/storefront-next-cartridge.html
7+
**/node_modules/**
8+
9+
!node_modules/
10+
!node_modules/@salesforce/
11+
!node_modules/@salesforce/b2c-tooling-sdk/
12+
!node_modules/@salesforce/b2c-tooling-sdk/package.json
13+
14+
!src/template/**
15+
.gitignore
16+
**/tsconfig.json
17+
**/eslint.config.mjs
18+
**/*.map
19+
**/*.ts
20+
**/.vscode-test.*
21+
**/.pnpm-store/**
22+
**/.turbo/**
23+
packages/**
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Change Log
2+
3+
All notable changes to the "wei-first-extension" extension will be documented in this file.
4+
5+
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
6+
7+
## [Unreleased]
8+
9+
- Initial release

0 commit comments

Comments
 (0)