Skip to content
Open
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
40 changes: 32 additions & 8 deletions support/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -119081,7 +119081,8 @@ var _TPartialRunDefinition = Type.Object({
defaultLogRetention: Type.Optional(TTemplateString2),
tasks: Type.Array(TPartialTaskDefinition),
baseConfig: TPartialBaseConfig,
warningMessages: Type.Array(TUserMessage)
warningMessages: Type.Array(TUserMessage),
tips: Type.Optional(Type.Array(TTip19))
});
var KEY_CHARSET = "[A-Za-z0-9_-]";
var KEY_INVALID_CHARSET = `[^A-Za-z0-9_-]`;
Expand Down Expand Up @@ -122135,6 +122136,7 @@ var YamlParser = class _YamlParser {
}
}
messages = [];
tipCollector = [];
linesMap;
sourceMap;
rootNode;
Expand Down Expand Up @@ -122287,6 +122289,7 @@ var YamlParser = class _YamlParser {
return {
tasks: [],
warningMessages: [],
...this.collectedRunTips(),
defaultAgentSpecification: { ...DEFAULT_AGENT_SPECIFICATION },
baseConfig: defaultBaseLayerSpecificationWithTemplateStrings()
};
Expand All @@ -122304,6 +122307,7 @@ var YamlParser = class _YamlParser {
return {
tasks: [],
warningMessages: [],
...this.collectedRunTips(),
defaultAgentSpecification: { ...DEFAULT_AGENT_SPECIFICATION },
baseConfig: defaultBaseLayerSpecificationWithTemplateStrings()
};
Expand All @@ -122323,7 +122327,8 @@ var YamlParser = class _YamlParser {
triggers: fields.on,
tasks: fields.tasks,
baseConfig: fields.base,
warningMessages: warningCollector
warningMessages: warningCollector,
...this.collectedRunTips()
};
};
parseTaskOrTaskList = async () => {
Expand Down Expand Up @@ -122442,8 +122447,8 @@ var YamlParser = class _YamlParser {
fileName: this.currentFileName,
deprecatedBaseFields: ["os", "tag"]
});
this.warning({
warningCollector,
this.tip({
key: "migrate-base-os-tag-to-image-config" /* MigrateBaseOsTagToImageConfig */,
node: keyNodes.os,
message: `The ${codeQuote("base.os")} and ${codeQuote("base.tag")} fields are deprecated.`,
advice: `Use ${codeQuote("base.image")} and ${codeQuote("base.config")} instead.`,
Expand All @@ -122454,8 +122459,8 @@ var YamlParser = class _YamlParser {
fileName: this.currentFileName,
deprecatedBaseFields: ["os"]
});
this.warning({
warningCollector,
this.tip({
key: "migrate-base-os-tag-to-image-config" /* MigrateBaseOsTagToImageConfig */,
node: keyNodes.os,
message: `The ${codeQuote("base.os")} field is deprecated.`,
advice: `Use ${codeQuote("base.image")} instead.`,
Expand All @@ -122466,8 +122471,8 @@ var YamlParser = class _YamlParser {
fileName: this.currentFileName,
deprecatedBaseFields: ["tag"]
});
this.warning({
warningCollector,
this.tip({
key: "migrate-base-os-tag-to-image-config" /* MigrateBaseOsTagToImageConfig */,
node: keyNodes.tag,
message: `The ${codeQuote("base.tag")} field is deprecated.`,
advice: `Use ${codeQuote("base.config")} instead.`,
Expand Down Expand Up @@ -124834,6 +124839,25 @@ var YamlParser = class _YamlParser {
})
);
}
collectedRunTips() {
if (this.tipCollector.length === 0) return {};
return { tips: this.tipCollector };
}
tip({ key, message, node, advice, docs }) {
const { line, column, endLine, endColumn } = this.locationRangeOfNode(node, this.currentFileName);
const stackEntry = { fileName: this.currentFileName, line, column, endLine, endColumn };
this.tipCollector.push({
key,
details: buildMessage({
type: "mint-tip" /* MintTip */,
message: [message],
advice: advice ? [advice] : [],
docs: docs ?? null,
stackTrace: [...this.stack, stackEntry],
frame: this.generateCodeFrame(stackEntry)
})
});
}
generateCodeFrame({ line, column, fileName, endLine, endColumn }) {
const frameLines = verifyExists(this.sourceMap[fileName]).split("\n");
const lineNumbers = [line - 2, line - 1, line, line + 1, line + 2].filter((l) => !!frameLines[l - 1]);
Expand Down