@vscode/vsce 3.9.3-5 → 3.9.3-7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,14 +15,7 @@ Read the [**Documentation**](https://code.visualstudio.com/api/working-with-exte
15
15
 
16
16
  ### Linux
17
17
 
18
- In order to save credentials safely, this project uses [`keytar`](https://www.npmjs.com/package/keytar) which uses `libsecret`, which you may need to install before publishing extensions. Setting the `VSCE_STORE=file` environment variable will revert back to the file credential store. Using the `VSCE_PAT` environment variable will also avoid using `keytar`.
19
-
20
- Depending on your distribution, you will need to run the following command:
21
-
22
- - Debian/Ubuntu: `sudo apt-get install libsecret-1-dev`
23
- - Alpine: `apk add libsecret`
24
- - Red Hat-based: `sudo yum install libsecret-devel`
25
- - Arch Linux: `sudo pacman -S libsecret`
18
+ In order to save credentials safely, this project uses [`@napi-rs/keyring`](https://www.npmjs.com/package/@napi-rs/keyring), which uses the system Secret Service and falls back to the Linux kernel keyring. Setting the `VSCE_STORE=file` environment variable will revert back to the file credential store. Using the `VSCE_PAT` environment variable will also avoid using the system credential store.
26
19
 
27
20
  ## Usage
28
21
 
package/out/npm.js CHANGED
@@ -105,8 +105,8 @@ function asYarnDependency(prefix, tree, prune) {
105
105
  }
106
106
  function selectYarnDependencies(deps, packagedDependencies) {
107
107
  const index = new (class {
108
+ data = Object.create(null);
108
109
  constructor() {
109
- this.data = Object.create(null);
110
110
  for (const dep of deps) {
111
111
  if (this.data[dep.name]) {
112
112
  throw Error(`Dependency seen more than once: ${dep.name}`);
@@ -123,9 +123,7 @@ function selectYarnDependencies(deps, packagedDependencies) {
123
123
  }
124
124
  })();
125
125
  const reached = new (class {
126
- constructor() {
127
- this.values = [];
128
- }
126
+ values = [];
129
127
  add(dep) {
130
128
  if (this.values.indexOf(dep) < 0) {
131
129
  this.values.push(dep);
package/out/oidc.js CHANGED
@@ -5,9 +5,7 @@ exports.getOIDCCredential = getOIDCCredential;
5
5
  const util_1 = require("./util");
6
6
  exports.OIDC_AUDIENCE = 'marketplace.visualstudio.com';
7
7
  class GitHubActionsOIDCTokenProvider {
8
- constructor() {
9
- this.name = 'GitHub Actions';
10
- }
8
+ name = 'GitHub Actions';
11
9
  isAvailable(environment) {
12
10
  return environment['GITHUB_ACTIONS']?.toLowerCase() === 'true';
13
11
  }
package/out/package.js CHANGED
@@ -67,8 +67,8 @@ const nls_1 = require("./nls");
67
67
  const util = __importStar(require("./util"));
68
68
  const glob_1 = require("glob");
69
69
  const minimatch_1 = require("minimatch");
70
- const markdown_it_1 = __importDefault(require("markdown-it"));
71
- const cheerio = __importStar(require("cheerio"));
70
+ const parse5_1 = require("parse5");
71
+ const marked_1 = require("marked");
72
72
  const url = __importStar(require("url"));
73
73
  const mime_1 = __importDefault(require("mime"));
74
74
  const semver = __importStar(require("semver"));
@@ -94,12 +94,13 @@ function read(file) {
94
94
  }
95
95
  }
96
96
  class BaseProcessor {
97
+ manifest;
97
98
  constructor(manifest) {
98
99
  this.manifest = manifest;
99
- this.assets = [];
100
- this.tags = [];
101
- this.vsix = Object.create(null);
102
100
  }
101
+ assets = [];
102
+ tags = [];
103
+ vsix = Object.create(null);
103
104
  async onFile(file) {
104
105
  return file;
105
106
  }
@@ -299,6 +300,7 @@ exports.Targets = new Set([
299
300
  'web',
300
301
  ]);
301
302
  class ManifestProcessor extends BaseProcessor {
303
+ options;
302
304
  constructor(manifest, options = {}) {
303
305
  super(manifest);
304
306
  this.options = options;
@@ -430,6 +432,44 @@ class ManifestProcessor extends BaseProcessor {
430
432
  }
431
433
  exports.ManifestProcessor = ManifestProcessor;
432
434
  class TagsProcessor extends BaseProcessor {
435
+ static Keywords = {
436
+ git: ['git'],
437
+ npm: ['node'],
438
+ spell: ['markdown'],
439
+ bootstrap: ['bootstrap'],
440
+ lint: ['linters'],
441
+ linting: ['linters'],
442
+ react: ['javascript'],
443
+ js: ['javascript'],
444
+ node: ['javascript', 'node'],
445
+ 'c++': ['c++'],
446
+ Cplusplus: ['c++'],
447
+ xml: ['xml'],
448
+ angular: ['javascript'],
449
+ jquery: ['javascript'],
450
+ php: ['php'],
451
+ python: ['python'],
452
+ latex: ['latex'],
453
+ ruby: ['ruby'],
454
+ java: ['java'],
455
+ erlang: ['erlang'],
456
+ sql: ['sql'],
457
+ nodejs: ['node'],
458
+ 'c#': ['c#'],
459
+ css: ['css'],
460
+ javascript: ['javascript'],
461
+ ftp: ['ftp'],
462
+ haskell: ['haskell'],
463
+ unity: ['unity'],
464
+ terminal: ['terminal'],
465
+ powershell: ['powershell'],
466
+ laravel: ['laravel'],
467
+ meteor: ['meteor'],
468
+ emmet: ['emmet'],
469
+ eslint: ['linters'],
470
+ tfs: ['tfs'],
471
+ rust: ['rust'],
472
+ };
433
473
  async onEnd() {
434
474
  const keywords = this.manifest.keywords ?? [];
435
475
  const contributes = this.manifest.contributes;
@@ -493,51 +533,25 @@ class TagsProcessor extends BaseProcessor {
493
533
  }
494
534
  }
495
535
  exports.TagsProcessor = TagsProcessor;
496
- TagsProcessor.Keywords = {
497
- git: ['git'],
498
- npm: ['node'],
499
- spell: ['markdown'],
500
- bootstrap: ['bootstrap'],
501
- lint: ['linters'],
502
- linting: ['linters'],
503
- react: ['javascript'],
504
- js: ['javascript'],
505
- node: ['javascript', 'node'],
506
- 'c++': ['c++'],
507
- Cplusplus: ['c++'],
508
- xml: ['xml'],
509
- angular: ['javascript'],
510
- jquery: ['javascript'],
511
- php: ['php'],
512
- python: ['python'],
513
- latex: ['latex'],
514
- ruby: ['ruby'],
515
- java: ['java'],
516
- erlang: ['erlang'],
517
- sql: ['sql'],
518
- nodejs: ['node'],
519
- 'c#': ['c#'],
520
- css: ['css'],
521
- javascript: ['javascript'],
522
- ftp: ['ftp'],
523
- haskell: ['haskell'],
524
- unity: ['unity'],
525
- terminal: ['terminal'],
526
- powershell: ['powershell'],
527
- laravel: ['laravel'],
528
- meteor: ['meteor'],
529
- emmet: ['emmet'],
530
- eslint: ['linters'],
531
- tfs: ['tfs'],
532
- rust: ['rust'],
533
- };
534
536
  class MarkdownProcessor extends BaseProcessor {
537
+ name;
538
+ assetType;
539
+ options;
540
+ regexp;
541
+ baseContentUrl;
542
+ baseImagesUrl;
543
+ rewriteRelativeLinks;
544
+ isGitHub;
545
+ isGitLab;
546
+ repositoryUrl;
547
+ gitHubIssueLinking;
548
+ gitLabIssueLinking;
549
+ filesProcessed = 0;
535
550
  constructor(manifest, name, filePath, assetType, options = {}) {
536
551
  super(manifest);
537
552
  this.name = name;
538
553
  this.assetType = assetType;
539
554
  this.options = options;
540
- this.filesProcessed = 0;
541
555
  this.regexp = new RegExp(`^${util.filePathToVsixPath(filePath)}$`, 'i');
542
556
  const guess = this.guessBaseUrls(options.githubBranch || options.gitlabBranch);
543
557
  this.baseContentUrl = options.baseContentUrl || (guess && guess.content);
@@ -627,11 +641,33 @@ class MarkdownProcessor extends BaseProcessor {
627
641
  contents = contents.replace(markdownIssueRegex, issueReplace);
628
642
  }
629
643
  }
630
- const html = (0, markdown_it_1.default)({ html: true }).render(contents);
631
- const $ = cheerio.load(html);
644
+ const html = marked_1.marked.parse(contents, { async: false });
645
+ const document = (0, parse5_1.parse)(html);
646
+ const images = [];
647
+ let hasSvg = false;
648
+ const nodes = [document];
649
+ while (nodes.length > 0) {
650
+ const node = nodes.pop();
651
+ if ('tagName' in node) {
652
+ if (node.tagName === 'img') {
653
+ images.push(node);
654
+ }
655
+ else if (node.tagName === 'svg') {
656
+ hasSvg = true;
657
+ }
658
+ }
659
+ const children = 'content' in node
660
+ ? node.content.childNodes
661
+ : 'childNodes' in node
662
+ ? node.childNodes
663
+ : [];
664
+ for (let index = children.length - 1; index >= 0; index--) {
665
+ nodes.push(children[index]);
666
+ }
667
+ }
632
668
  if (this.rewriteRelativeLinks) {
633
- $('img').each((_, img) => {
634
- const rawSrc = $(img).attr('src');
669
+ for (const image of images) {
670
+ const rawSrc = image.attrs.find(attribute => attribute.name === 'src')?.value;
635
671
  if (!rawSrc) {
636
672
  throw new Error(`Images in ${this.name} must have a source.`);
637
673
  }
@@ -652,11 +688,11 @@ class MarkdownProcessor extends BaseProcessor {
652
688
  if (/\.svg$/i.test(srcUrl.pathname) && !isHostTrusted(srcUrl)) {
653
689
  throw new Error(`SVGs are restricted in ${this.name}; please use other file image formats, such as PNG: ${src}`);
654
690
  }
655
- });
691
+ }
656
692
  }
657
- $('svg').each(() => {
693
+ if (hasSvg) {
658
694
  throw new Error(`SVG tags are not allowed in ${this.name}.`);
659
- });
695
+ }
660
696
  return {
661
697
  path: file.path,
662
698
  contents: Buffer.from(contents, 'utf8'),
@@ -734,10 +770,13 @@ class ChangelogProcessor extends MarkdownProcessor {
734
770
  }
735
771
  exports.ChangelogProcessor = ChangelogProcessor;
736
772
  class LicenseProcessor extends BaseProcessor {
773
+ options;
774
+ didFindLicense = false;
775
+ expectedLicenseName;
776
+ filter;
737
777
  constructor(manifest, options = {}) {
738
778
  super(manifest);
739
779
  this.options = options;
740
- this.didFindLicense = false;
741
780
  const match = /^SEE LICENSE IN (.*)$/.exec(manifest.license || '');
742
781
  if (!match || !match[1]) {
743
782
  this.expectedLicenseName = 'LICENSE, LICENSE.md, or LICENSE.txt';
@@ -776,9 +815,9 @@ class LicenseProcessor extends BaseProcessor {
776
815
  }
777
816
  exports.LicenseProcessor = LicenseProcessor;
778
817
  class LaunchEntryPointProcessor extends BaseProcessor {
818
+ seenFiles = new Set();
779
819
  constructor(manifest) {
780
820
  super(manifest);
781
- this.seenFiles = new Set();
782
821
  }
783
822
  onFile(file) {
784
823
  this.seenFiles.add(util.normalize(file.path));
@@ -811,9 +850,10 @@ class LaunchEntryPointProcessor extends BaseProcessor {
811
850
  }
812
851
  }
813
852
  class IconProcessor extends BaseProcessor {
853
+ icon;
854
+ didFindIcon = false;
814
855
  constructor(manifest) {
815
856
  super(manifest);
816
- this.didFindIcon = false;
817
857
  this.icon = manifest.icon && path.posix.normalize(util.filePathToVsixPath(manifest.icon));
818
858
  delete this.vsix.icon;
819
859
  }
@@ -893,9 +933,9 @@ function deduceExtensionKinds(manifest) {
893
933
  return result;
894
934
  }
895
935
  class NLSProcessor extends BaseProcessor {
936
+ translations = Object.create(null);
896
937
  constructor(manifest) {
897
938
  super(manifest);
898
- this.translations = Object.create(null);
899
939
  if (!manifest.contributes ||
900
940
  !manifest.contributes.localizations ||
901
941
  manifest.contributes.localizations.length === 0) {
@@ -928,11 +968,8 @@ class NLSProcessor extends BaseProcessor {
928
968
  }
929
969
  exports.NLSProcessor = NLSProcessor;
930
970
  class ValidationProcessor extends BaseProcessor {
931
- constructor() {
932
- super(...arguments);
933
- this.files = new Map();
934
- this.duplicates = new Set();
935
- }
971
+ files = new Map();
972
+ duplicates = new Set();
936
973
  async onFile(file) {
937
974
  const lower = file.path.toLowerCase();
938
975
  const existing = this.files.get(lower);
@@ -5,10 +5,12 @@ const HttpClient_1 = require("typed-rest-client/HttpClient");
5
5
  const GalleryInterfaces_1 = require("azure-devops-node-api/interfaces/GalleryInterfaces");
6
6
  const Serialization_1 = require("azure-devops-node-api/Serialization");
7
7
  class PublicGalleryAPI {
8
+ baseUrl;
9
+ apiVersion;
10
+ client = new HttpClient_1.HttpClient('vsce');
8
11
  constructor(baseUrl, apiVersion = '3.0-preview.1') {
9
12
  this.baseUrl = baseUrl;
10
13
  this.apiVersion = apiVersion;
11
- this.client = new HttpClient_1.HttpClient('vsce');
12
14
  }
13
15
  post(url, data, additionalHeaders) {
14
16
  return this.client.post(`${this.baseUrl}/_apis/public${url}`, data, additionalHeaders);
package/out/publish.js CHANGED
@@ -40,21 +40,28 @@ exports.publish = publish;
40
40
  exports.unpublish = unpublish;
41
41
  exports.getPAT = getPAT;
42
42
  const fs = __importStar(require("fs"));
43
- const util_1 = require("util");
44
43
  const semver = __importStar(require("semver"));
45
44
  const GalleryInterfaces_1 = require("azure-devops-node-api/interfaces/GalleryInterfaces");
46
45
  const package_1 = require("./package");
47
- const tmp = __importStar(require("tmp"));
48
46
  const store_1 = require("./store");
49
- const util_2 = require("./util");
47
+ const util_1 = require("./util");
50
48
  const zip_1 = require("./zip");
51
49
  const validation_1 = require("./validation");
52
50
  const form_data_1 = __importDefault(require("form-data"));
53
51
  const path_1 = require("path");
52
+ const os_1 = require("os");
54
53
  const cockatiel_1 = require("cockatiel");
55
54
  const auth_1 = require("./auth");
56
55
  const oidc_1 = require("./oidc");
57
- const tmpName = (0, util_1.promisify)(tmp.tmpName);
56
+ async function withTemporaryPackage(fn) {
57
+ const directory = await fs.promises.mkdtemp((0, path_1.join)((0, os_1.tmpdir)(), 'vsce-'));
58
+ try {
59
+ return await fn((0, path_1.join)(directory, 'extension.vsix'));
60
+ }
61
+ finally {
62
+ await fs.promises.rm(directory, { recursive: true, force: true });
63
+ }
64
+ }
58
65
  async function publish(options = {}) {
59
66
  validateAuthenticationOptions(options);
60
67
  if (options.packagePath) {
@@ -108,38 +115,40 @@ async function publish(options = {}) {
108
115
  else {
109
116
  const cwd = options.cwd || process.cwd();
110
117
  const manifest = await (0, package_1.readManifest)(cwd);
111
- (0, util_2.patchOptionsWithManifest)(options, manifest);
118
+ (0, util_1.patchOptionsWithManifest)(options, manifest);
112
119
  // Validate marketplace requirements before prepublish to avoid unnecessary work
113
120
  validateManifestForPublishing(manifest, options);
114
121
  await (0, package_1.prepublish)(cwd, manifest, options.useYarn);
115
122
  await (0, package_1.versionBump)(options);
116
123
  if (options.targets) {
117
124
  for (const target of options.targets) {
118
- const packagePath = await tmpName();
119
- const packageResult = await (0, package_1.pack)({ ...options, target, packagePath });
120
- const manifestValidated = validateManifestForPublishing(packageResult.manifest, options);
121
- const sigzipPath = options.signTool ? await (0, package_1.signPackage)(packagePath, options.signTool) : undefined;
122
- await _publish(packagePath, sigzipPath, manifestValidated, { ...options, target });
125
+ await withTemporaryPackage(async (packagePath) => {
126
+ const packageResult = await (0, package_1.pack)({ ...options, target, packagePath });
127
+ const manifestValidated = validateManifestForPublishing(packageResult.manifest, options);
128
+ const sigzipPath = options.signTool ? await (0, package_1.signPackage)(packagePath, options.signTool) : undefined;
129
+ await _publish(packagePath, sigzipPath, manifestValidated, { ...options, target });
130
+ });
123
131
  }
124
132
  }
125
133
  else {
126
- const packagePath = await tmpName();
127
- const packageResult = await (0, package_1.pack)({ ...options, packagePath });
128
- const manifestValidated = validateManifestForPublishing(packageResult.manifest, options);
129
- const sigzipPath = options.signTool ? await (0, package_1.signPackage)(packagePath, options.signTool) : undefined;
130
- await _publish(packagePath, sigzipPath, manifestValidated, options);
134
+ await withTemporaryPackage(async (packagePath) => {
135
+ const packageResult = await (0, package_1.pack)({ ...options, packagePath });
136
+ const manifestValidated = validateManifestForPublishing(packageResult.manifest, options);
137
+ const sigzipPath = options.signTool ? await (0, package_1.signPackage)(packagePath, options.signTool) : undefined;
138
+ await _publish(packagePath, sigzipPath, manifestValidated, options);
139
+ });
131
140
  }
132
141
  }
133
142
  }
134
143
  async function _publish(packagePath, sigzipPath, manifest, options) {
135
144
  const pat = await getPAT(manifest.publisher, options);
136
- const api = await (0, util_2.getGalleryAPI)(pat);
145
+ const api = await (0, util_1.getGalleryAPI)(pat);
137
146
  const packageStream = fs.createReadStream(packagePath);
138
147
  const name = `${manifest.publisher}.${manifest.name}`;
139
148
  const description = options.target
140
149
  ? `${name} (${options.target}) v${manifest.version}`
141
150
  : `${name} v${manifest.version}`;
142
- util_2.log.info(`Publishing '${description}'...`);
151
+ util_1.log.info(`Publishing '${description}'...`);
143
152
  let extension = null;
144
153
  try {
145
154
  try {
@@ -155,7 +164,7 @@ async function _publish(packagePath, sigzipPath, manifest, options) {
155
164
  (v.targetPlatform === options.target));
156
165
  if (versionExists) {
157
166
  if (options.skipDuplicate) {
158
- util_2.log.done(`Version ${manifest.version} is already published. Skipping publish.`);
167
+ util_1.log.done(`Version ${manifest.version} is already published. Skipping publish.`);
159
168
  return;
160
169
  }
161
170
  else {
@@ -172,7 +181,7 @@ async function _publish(packagePath, sigzipPath, manifest, options) {
172
181
  catch (err) {
173
182
  if (err.statusCode === 409) {
174
183
  if (options.skipDuplicate) {
175
- util_2.log.done(`Version ${manifest.version} is already published. Skipping publish.`);
184
+ util_1.log.done(`Version ${manifest.version} is already published. Skipping publish.`);
176
185
  return;
177
186
  }
178
187
  else {
@@ -204,9 +213,9 @@ async function _publish(packagePath, sigzipPath, manifest, options) {
204
213
  }
205
214
  throw err;
206
215
  }
207
- util_2.log.info(`Extension URL (might take a few minutes): ${(0, util_2.getPublishedUrl)(name)}`);
208
- util_2.log.info(`Hub URL: ${(0, util_2.getHubUrl)(manifest.publisher, manifest.name)}`);
209
- util_2.log.done(`Published ${description}.`);
216
+ util_1.log.info(`Extension URL (might take a few minutes): ${(0, util_1.getPublishedUrl)(name)}`);
217
+ util_1.log.info(`Hub URL: ${(0, util_1.getHubUrl)(manifest.publisher, manifest.name)}`);
218
+ util_1.log.done(`Published ${description}.`);
210
219
  }
211
220
  async function _publishSignedPackage(api, packageName, packageStream, sigzipName, sigzipStream, manifest) {
212
221
  const extensionType = 'Visual Studio Code';
@@ -221,7 +230,7 @@ async function _publishSignedPackage(api, packageName, packageStream, sigzipName
221
230
  });
222
231
  const publishWithRetry = (0, cockatiel_1.retry)((0, cockatiel_1.handleWhen)(err => err.message.includes('timeout')), {
223
232
  maxAttempts: 3,
224
- backoff: new cockatiel_1.IterableBackoff([5000, 10000, 20000])
233
+ backoff: new cockatiel_1.IterableBackoff([5_000, 10_000, 20_000])
225
234
  });
226
235
  return await publishWithRetry.execute(async () => {
227
236
  return await api.publishExtensionWithPublisherSignature(undefined, form, manifest.publisher, manifest.name, extensionType);
@@ -239,15 +248,15 @@ async function unpublish(options = {}) {
239
248
  }
240
249
  const fullName = `${publisher}.${name}`;
241
250
  if (!options.force) {
242
- const answer = await (0, util_2.read)(`This will delete ALL published versions! Please type '${fullName}' to confirm: `);
251
+ const answer = await (0, util_1.read)(`This will delete ALL published versions! Please type '${fullName}' to confirm: `);
243
252
  if (answer !== fullName) {
244
253
  throw new Error('Aborted');
245
254
  }
246
255
  }
247
256
  const pat = await getPAT(publisher, options);
248
- const api = await (0, util_2.getGalleryAPI)(pat);
257
+ const api = await (0, util_1.getGalleryAPI)(pat);
249
258
  await api.deleteExtension(publisher, name);
250
- util_2.log.done(`Deleted extension: ${fullName}!`);
259
+ util_1.log.done(`Deleted extension: ${fullName}!`);
251
260
  }
252
261
  function validateManifestForPublishing(manifest, options) {
253
262
  if (manifest.enableProposedApi && !options.allowAllProposedApis && !options.noVerify) {
package/out/secretLint.js CHANGED
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -8,7 +41,8 @@ exports.lintText = lintText;
8
41
  exports.getRuleNameFromRuleId = getRuleNameFromRuleId;
9
42
  exports.prettyPrintLintResult = prettyPrintLintResult;
10
43
  const chalk_1 = __importDefault(require("chalk"));
11
- const secret_lint_types_1 = require("./typings/secret-lint-types");
44
+ const path = __importStar(require("path"));
45
+ const url_1 = require("url");
12
46
  const util_1 = require("./util");
13
47
  const secretsScanningRules = [
14
48
  {
@@ -45,11 +79,8 @@ const dotEnvRules = [
45
79
  id: "@secretlint/secretlint-rule-no-dotenv"
46
80
  }
47
81
  ];
48
- // Helper function to dynamically import the createEngine function
49
82
  async function getEngine(scanSecrets, scanDotEnv) {
50
- // Use a raw dynamic import that will not be transformed
51
- // This is necessary because @secretlint/node is an ESM module
52
- const secretlintModule = await eval('import("@secretlint/node")');
83
+ const { createEngine } = require("@secretlint/node");
53
84
  const rules = [];
54
85
  if (scanSecrets) {
55
86
  rules.push(...secretsScanningRules);
@@ -59,11 +90,11 @@ async function getEngine(scanSecrets, scanDotEnv) {
59
90
  }
60
91
  const lintOptions = {
61
92
  configFileJSON: { rules: rules },
62
- formatter: "@secretlint/secretlint-formatter-sarif", // checkstyle, compact, jslint-xml, junit, pretty-error, stylish, tap, unix, json, mask-result, table
93
+ formatter: "json",
63
94
  color: true,
64
95
  maskSecrets: false
65
96
  };
66
- const engine = await secretlintModule.createEngine(lintOptions);
97
+ const engine = await createEngine(lintOptions);
67
98
  return engine;
68
99
  }
69
100
  async function lintFiles(filePaths, scanSecrets, scanDotEnv) {
@@ -96,49 +127,78 @@ async function lintText(content, fileName, scanSecrets, scanDotEnv) {
96
127
  return parseResult(engineResult);
97
128
  }
98
129
  function parseResult(result) {
99
- const output = secret_lint_types_1.Convert.toSecretLintOutput(result.output);
100
- const results = output.runs.at(0)?.results ?? [];
130
+ const output = JSON.parse(result.output);
131
+ if (!Array.isArray(output) || !output.every(isSecretLintFileResult)) {
132
+ throw new Error("Unexpected output from secretlint");
133
+ }
134
+ const results = output.flatMap(fileResult => fileResult.messages.map((message) => ({
135
+ message: message.message,
136
+ ruleId: message.ruleParentId ? `${message.ruleParentId} > ${message.ruleId}` : message.ruleId,
137
+ level: message.severity === "info" ? "note" : message.severity,
138
+ filePath: process.env.SARIF_URI_ABSOLUTE
139
+ ? (0, url_1.pathToFileURL)(fileResult.filePath).toString()
140
+ : path.relative(process.cwd(), fileResult.filePath),
141
+ startLine: fixLine(message.loc.start.line),
142
+ startColumn: fixColumn(message.loc.start.column),
143
+ endLine: fixLine(message.loc.end.line),
144
+ endColumn: fixColumn(message.loc.end.column)
145
+ })));
101
146
  return { ok: result.ok, results };
102
147
  }
148
+ function isSecretLintFileResult(value) {
149
+ return isRecord(value)
150
+ && typeof value.filePath === "string"
151
+ && Array.isArray(value.messages)
152
+ && value.messages.every(isSecretLintMessage);
153
+ }
154
+ function isSecretLintMessage(value) {
155
+ return isRecord(value)
156
+ && typeof value.message === "string"
157
+ && typeof value.ruleId === "string"
158
+ && (value.ruleParentId === undefined || typeof value.ruleParentId === "string")
159
+ && isRecord(value.loc)
160
+ && isSecretLintPosition(value.loc.start)
161
+ && isSecretLintPosition(value.loc.end)
162
+ && (value.severity === "error" || value.severity === "warning" || value.severity === "info");
163
+ }
164
+ function isSecretLintPosition(value) {
165
+ return isRecord(value)
166
+ && (value.line === null || typeof value.line === "number")
167
+ && (value.column === null || typeof value.column === "number");
168
+ }
169
+ function isRecord(value) {
170
+ return typeof value === "object" && value !== null;
171
+ }
172
+ function fixLine(value) {
173
+ return value === null ? undefined : value === 0 ? 1 : value;
174
+ }
175
+ function fixColumn(value) {
176
+ return value === null ? undefined : value === 0 ? 1 : value + 1;
177
+ }
103
178
  function getRuleNameFromRuleId(ruleId) {
104
179
  const parts = ruleId.split('-rule-');
105
180
  return parts[parts.length - 1];
106
181
  }
107
182
  function prettyPrintLintResult(result) {
108
- if (!result.message.text) {
109
- return JSON.stringify(result);
110
- }
111
- const text = result.message.text;
112
- const titleColor = result.level === undefined || result.level === secret_lint_types_1.Level.Error ? chalk_1.default.bold.red : chalk_1.default.bold.yellow;
183
+ const text = result.message;
184
+ const titleColor = result.level === "error" ? chalk_1.default.bold.red : chalk_1.default.bold.yellow;
113
185
  const title = text.length > 54 ? text.slice(0, 50) + '...' : text;
114
- const ruleName = result.ruleId ? getRuleNameFromRuleId(result.ruleId) : 'unknown';
186
+ const ruleName = getRuleNameFromRuleId(result.ruleId);
115
187
  let output = `\t${titleColor(title)} [${ruleName}]\n`;
116
- if (result.locations) {
117
- result.locations.forEach(location => {
118
- output += `\t${prettyPrintLocation(location)}\n`;
119
- });
120
- }
188
+ output += `\t${prettyPrintLocation(result)}\n`;
121
189
  return output;
122
190
  }
123
- function prettyPrintLocation(location) {
124
- if (!location.physicalLocation) {
125
- return JSON.stringify(location);
126
- }
127
- const uri = location.physicalLocation.artifactLocation?.uri;
128
- if (!uri) {
129
- return JSON.stringify(location);
130
- }
131
- let output = uri;
132
- const region = location.physicalLocation.region;
133
- const regionStringified = region ? prettyPrintRegion(region) : undefined;
191
+ function prettyPrintLocation(result) {
192
+ let output = result.filePath;
193
+ const regionStringified = prettyPrintRegion(result);
134
194
  if (regionStringified) {
135
195
  output += `#${regionStringified}`;
136
196
  }
137
197
  return output;
138
198
  }
139
- function prettyPrintRegion(region) {
140
- const startPosition = prettyPrintPosition(region.startLine, region.startColumn);
141
- const endPosition = prettyPrintPosition(region.endLine, region.endColumn);
199
+ function prettyPrintRegion(result) {
200
+ const startPosition = prettyPrintPosition(result.startLine, result.startColumn);
201
+ const endPosition = prettyPrintPosition(result.endLine, result.endColumn);
142
202
  if (!startPosition) {
143
203
  return undefined;
144
204
  }
package/out/store.js CHANGED
@@ -49,6 +49,9 @@ const package_1 = require("./package");
49
49
  const publish_1 = require("./publish");
50
50
  ;
51
51
  class FileStore {
52
+ path;
53
+ publishers;
54
+ static DefaultPath = path.join((0, os_1.homedir)(), '.vsce');
52
55
  static async open(path = FileStore.DefaultPath) {
53
56
  try {
54
57
  const rawStore = await fs.promises.readFile(path, 'utf8');
@@ -98,10 +101,12 @@ class FileStore {
98
101
  }
99
102
  }
100
103
  exports.FileStore = FileStore;
101
- FileStore.DefaultPath = path.join((0, os_1.homedir)(), '.vsce');
102
104
  class KeytarStore {
105
+ keytar;
106
+ serviceName;
107
+ publishers;
103
108
  static async open(serviceName = 'vscode-vsce') {
104
- const keytar = await import('keytar').then(module => module.default);
109
+ const keytar = require('@napi-rs/keyring/keytar.js');
105
110
  const creds = await keytar.findCredentials(serviceName);
106
111
  return new KeytarStore(keytar, serviceName, creds.map(({ account, password }) => ({ name: account, pat: password })));
107
112
  }