Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ You can configure the behavior of `vsce` by using CLI flags (run `vsce --help` t
$ npx @vscode/vsce publish --baseImagesUrl https://my.custom/base/images/url
```

Or you can also set them in the `package.json`, so that you avoid having to retype the common options again. Example:
You can define the options for `publish` and `package` the `package.json` under the `vsce` property, so that you avoid having to retype the common options again. Example:

```jsonc
// package.json
Expand Down
5 changes: 4 additions & 1 deletion src/manifest.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import type { IPackageOptions } from "./package";
import type { IPublishOptions } from "./publish";

export interface Person {
name: string;
url?: string;
Expand Down Expand Up @@ -110,7 +113,7 @@ export interface ManifestPackage {
files?: string[];

// vsce
vsce?: any;
vsce?: Partial<IPackageOptions & IPublishOptions>;

// not supported (npm)
// bin
Expand Down
1 change: 1 addition & 0 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2040,6 +2040,7 @@ interface ILSOptions {
export async function ls(options: ILSOptions = {}): Promise<void> {
const cwd = process.cwd();
const manifest = await readManifest(cwd);
util.patchOptionsWithManifest(options, manifest);

const files = await listFiles({ ...options, cwd, manifest });

Expand Down
16 changes: 12 additions & 4 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { PublicGalleryAPI } from './publicgalleryapi';
import { ISecurityRolesApi } from 'azure-devops-node-api/SecurityRolesApi';
import { ManifestPackage } from './manifest';
import { EOL } from 'os';
import type { IPublishOptions } from './publish';
import type { IPackageOptions } from './package';

const __read = promisify<_read.Options, string>(_read);
export function read(prompt: string, options: _read.Options = {}): Promise<string> {
Expand Down Expand Up @@ -171,16 +173,22 @@ export const log = {
error: _log.bind(null, LogMessageType.ERROR) as LogFn,
};

export function patchOptionsWithManifest(options: any, manifest: ManifestPackage): void {
type Writable<T> = {
-readonly [key in keyof T]: T[key];
};
type PatchableOptions = IPublishOptions | IPackageOptions;

export function patchOptionsWithManifest(options: PatchableOptions, manifest: ManifestPackage): void {
if (!manifest.vsce) {
return;
}

for (const key of Object.keys(manifest.vsce)) {
const optionsKey = key === 'yarn' ? 'useYarn' : key;
const optionsKey = (key === 'yarn' ? 'useYarn' : key) as keyof PatchableOptions;

if (options[optionsKey] === undefined) {
options[optionsKey] = manifest.vsce[key];
const value = manifest.vsce[key as keyof typeof manifest.vsce];
(options as Writable<IPackageOptions>)[optionsKey] = value as any;
}
}
}
Expand Down Expand Up @@ -229,7 +237,7 @@ export async function generateFileStructureTree(rootFolder: string, filePaths: {
// Create the node if it doesn't exist
if (!currentLevel[part]) {
if (isFile) {
// The file size is stored in the leaf node,
// The file size is stored in the leaf node,
currentLevel[part] = 0;
} else {
// The folder size is stored in the folder node
Expand Down