@actions/languageserver 0.3.26 → 0.3.27

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.
@@ -23412,6 +23412,7 @@ function getJobContext(workflowContext) {
23412
23412
  jobContext.add("services", servicesContext);
23413
23413
  }
23414
23414
  jobContext.add("status", new data_exports.Null());
23415
+ jobContext.add("check_run_id", new data_exports.Null());
23415
23416
  return jobContext;
23416
23417
  }
23417
23418
  function createContainerContext(container, isServices) {
@@ -24511,14 +24512,12 @@ ${indentation}${indentation}`;
24511
24512
  ${indentation}`;
24512
24513
  }
24513
24514
  break;
24514
- case DefinitionType.OneOf:
24515
- if (mode == DefinitionValueMode.Key) {
24516
- insertText = `
24517
- ${indentation}${key}: `;
24518
- } else {
24519
- insertText = `${key}: `;
24520
- }
24521
- break;
24515
+ case DefinitionType.OneOf: {
24516
+ const oneOfDef = typeDef;
24517
+ const expanded = expandOneOfToCompletions(oneOfDef, definitions, key, description, indentation, mode);
24518
+ properties.push(...expanded);
24519
+ continue;
24520
+ }
24522
24521
  case DefinitionType.String:
24523
24522
  case DefinitionType.Boolean:
24524
24523
  if (mode == DefinitionValueMode.Key) {
@@ -24555,6 +24554,69 @@ function distinctValues(values) {
24555
24554
  }
24556
24555
  return Array.from(map.values());
24557
24556
  }
24557
+ function getStructuralBucket(defType) {
24558
+ switch (defType) {
24559
+ case DefinitionType.Sequence:
24560
+ return "sequence";
24561
+ case DefinitionType.Mapping:
24562
+ return "mapping";
24563
+ default:
24564
+ return "scalar";
24565
+ }
24566
+ }
24567
+ function expandOneOfToCompletions(oneOfDef, definitions, key, description, indentation, mode) {
24568
+ const buckets = {
24569
+ scalar: false,
24570
+ sequence: false,
24571
+ mapping: false
24572
+ };
24573
+ for (const variantKey of oneOfDef.oneOf) {
24574
+ const variantDef = definitions[variantKey];
24575
+ if (variantDef) {
24576
+ const bucket = getStructuralBucket(variantDef.definitionType);
24577
+ buckets[bucket] = true;
24578
+ }
24579
+ }
24580
+ const results = [];
24581
+ const bucketCount = [buckets.scalar, buckets.sequence, buckets.mapping].filter(Boolean).length;
24582
+ const needsQualifier = bucketCount > 1;
24583
+ if (buckets.scalar) {
24584
+ const insertText = mode === DefinitionValueMode.Key ? `
24585
+ ${indentation}${key}: ` : `${key}: `;
24586
+ results.push({
24587
+ label: key,
24588
+ description,
24589
+ insertText
24590
+ });
24591
+ }
24592
+ if (buckets.sequence) {
24593
+ const insertText = mode === DefinitionValueMode.Key ? `
24594
+ ${indentation}${key}:
24595
+ ${indentation}${indentation}- ` : `${key}:
24596
+ ${indentation}- `;
24597
+ results.push({
24598
+ label: needsQualifier ? `${key} (list)` : key,
24599
+ description,
24600
+ insertText,
24601
+ filterText: needsQualifier ? key : void 0,
24602
+ sortText: needsQualifier ? `${key} 1` : void 0
24603
+ });
24604
+ }
24605
+ if (buckets.mapping) {
24606
+ const insertText = mode === DefinitionValueMode.Key ? `
24607
+ ${indentation}${key}:
24608
+ ${indentation}${indentation}` : `${key}:
24609
+ ${indentation}`;
24610
+ results.push({
24611
+ label: needsQualifier ? `${key} (full syntax)` : key,
24612
+ description,
24613
+ insertText,
24614
+ filterText: needsQualifier ? key : void 0,
24615
+ sortText: needsQualifier ? `${key} 2` : void 0
24616
+ });
24617
+ }
24618
+ return results;
24619
+ }
24558
24620
 
24559
24621
  // ../languageservice/dist/complete.js
24560
24622
  function getExpressionInput(input, pos) {
@@ -24619,6 +24681,8 @@ async function complete2(textDocument, position, config) {
24619
24681
  const newText = value.insertText || value.label;
24620
24682
  const item = {
24621
24683
  label: value.label,
24684
+ filterText: value.filterText,
24685
+ sortText: value.sortText,
24622
24686
  documentation: value.description && {
24623
24687
  kind: "markdown",
24624
24688
  value: value.description
@@ -24702,7 +24766,7 @@ function getExpressionCompletionItems(token, context, pos) {
24702
24766
  }
24703
24767
  function filterAndSortCompletionOptions(options, existingValues) {
24704
24768
  options = options.filter((x) => !existingValues?.has(x.label));
24705
- options.sort((a, b) => a.label.localeCompare(b.label));
24769
+ options.sort((a, b) => (a.sortText ?? a.label).localeCompare(b.sortText ?? b.label));
24706
24770
  return options;
24707
24771
  }
24708
24772
  function mapExpressionCompletionItem(item, charAfterPos) {
@@ -25744,6 +25808,23 @@ function validateCronExpression(diagnostics, token) {
25744
25808
  });
25745
25809
  }
25746
25810
  }
25811
+ var SHORT_SHA_PATTERN = /^[0-9a-f]{7,8}$/i;
25812
+ var SHORT_SHA_DOCS_URL = "https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-third-party-actions";
25813
+ function warnIfShortSha(diagnostics, token, ref) {
25814
+ if (SHORT_SHA_PATTERN.test(ref)) {
25815
+ diagnostics.push({
25816
+ message: `The provided ref '${ref}' may be a shortened commit SHA. If so, please use the full 40-character commit SHA instead, as short SHAs are not supported.`,
25817
+ severity: import_vscode_languageserver_types3.DiagnosticSeverity.Warning,
25818
+ range: mapRange(token.range),
25819
+ code: "short-sha-ref",
25820
+ codeDescription: {
25821
+ href: SHORT_SHA_DOCS_URL
25822
+ }
25823
+ });
25824
+ return true;
25825
+ }
25826
+ return false;
25827
+ }
25747
25828
  function validateStepUsesFormat(diagnostics, token) {
25748
25829
  const uses = token.value;
25749
25830
  if (!uses) {
@@ -25785,6 +25866,7 @@ function validateStepUsesFormat(diagnostics, token) {
25785
25866
  });
25786
25867
  return;
25787
25868
  }
25869
+ warnIfShortSha(diagnostics, token, gitRef);
25788
25870
  }
25789
25871
  function addStepUsesFormatError(diagnostics, token) {
25790
25872
  diagnostics.push({
@@ -25873,6 +25955,7 @@ function validateWorkflowUsesFormat(diagnostics, token) {
25873
25955
  addWorkflowUsesFormatError(diagnostics, token, "invalid workflow file name");
25874
25956
  return;
25875
25957
  }
25958
+ warnIfShortSha(diagnostics, token, version);
25876
25959
  }
25877
25960
  function addWorkflowUsesFormatError(diagnostics, token, reason) {
25878
25961
  diagnostics.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@actions/languageserver",
3
- "version": "0.3.26",
3
+ "version": "0.3.27",
4
4
  "description": "Language server for GitHub Actions",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -48,8 +48,8 @@
48
48
  "actions-languageserver": "./bin/actions-languageserver"
49
49
  },
50
50
  "dependencies": {
51
- "@actions/languageservice": "^0.3.26",
52
- "@actions/workflow-parser": "^0.3.26",
51
+ "@actions/languageservice": "^0.3.27",
52
+ "@actions/workflow-parser": "^0.3.27",
53
53
  "@octokit/rest": "^21.1.1",
54
54
  "@octokit/types": "^9.0.0",
55
55
  "vscode-languageserver": "^8.0.2",
@@ -78,5 +78,5 @@
78
78
  "ts-jest": "^29.0.3",
79
79
  "typescript": "^4.8.4"
80
80
  },
81
- "gitHead": "c0062e5287fdb80b0856bc209e8dad064564bc70"
81
+ "gitHead": "86888cf4c8e058f83742597bb5e3cce4698742d8"
82
82
  }