pxt-core 8.1.2 → 8.1.3
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/built/buildengine.js +3 -3
- package/built/cli.js +35 -18
- package/built/nodeutil.d.ts +9 -1
- package/built/nodeutil.js +5 -4
- package/built/pxt.js +149 -122
- package/built/pxtcompiler.js +112 -103
- package/built/pxtsim.js +2 -1
- package/built/target.js +1 -1
- package/built/web/main.js +1 -1
- package/built/web/pxtapp.js +1 -1
- package/built/web/pxtcompiler.js +1 -1
- package/built/web/pxtembed.js +2 -2
- package/built/web/pxtsim.js +1 -1
- package/built/web/pxtworker.js +1 -1
- package/package.json +1 -1
package/built/pxt.js
CHANGED
|
@@ -125963,6 +125963,101 @@ ${output}</xml>`;
|
|
|
125963
125963
|
}
|
|
125964
125964
|
return undefined;
|
|
125965
125965
|
}
|
|
125966
|
+
/**
|
|
125967
|
+
* We split up comments according to the following rules:
|
|
125968
|
+
* 1. If the comment is not top-level:
|
|
125969
|
+
* a. Combine it with all comments for the following statement
|
|
125970
|
+
* b. If there is no following statement in the current block, group it with the previous statement
|
|
125971
|
+
* c. If there are no statements inside the block, group it with the parent block
|
|
125972
|
+
* d. If trailing the same line as the statement, group it with the comments for that statement
|
|
125973
|
+
* 2. If the comment is top-level:
|
|
125974
|
+
* b. If the comment is followed by an empty line, it becomes a workspace comment
|
|
125975
|
+
* c. If the comment is followed by a multi-line comment, it becomes a workspace comment
|
|
125976
|
+
* a. If the comment is a single-line comment, combine it with the next single-line comment
|
|
125977
|
+
* d. If the comment is not followed with an empty line, group it with the next statement or event
|
|
125978
|
+
* e. All other comments are workspace comments
|
|
125979
|
+
*
|
|
125980
|
+
* The below function gathers any comments associated to the Node, and attaches them
|
|
125981
|
+
* to the StatementNode.
|
|
125982
|
+
*/
|
|
125983
|
+
function getNodeComments(commented, stmt) {
|
|
125984
|
+
let comments = [];
|
|
125985
|
+
let current;
|
|
125986
|
+
for (let i = 0; i < commentMap.length; i++) {
|
|
125987
|
+
current = commentMap[i];
|
|
125988
|
+
if (!current.owner && current.start >= commented.pos && current.end <= commented.end) {
|
|
125989
|
+
current.owner = commented;
|
|
125990
|
+
current.ownerStatement = stmt;
|
|
125991
|
+
comments.push(current);
|
|
125992
|
+
}
|
|
125993
|
+
if (current.start > commented.end)
|
|
125994
|
+
break;
|
|
125995
|
+
}
|
|
125996
|
+
if (current && current.isTrailingComment) {
|
|
125997
|
+
const endLine = ts.getLineAndCharacterOfPosition(file, commented.end);
|
|
125998
|
+
const commentLine = ts.getLineAndCharacterOfPosition(file, current.start);
|
|
125999
|
+
if (endLine.line === commentLine.line) {
|
|
126000
|
+
// If the comment is trailing and on the same line as the statement, it probably belongs
|
|
126001
|
+
// to this statement. Remove it from any statement it's already assigned to and any workspace
|
|
126002
|
+
// comments
|
|
126003
|
+
if (current.ownerStatement) {
|
|
126004
|
+
current.ownerStatement.comment.splice(current.ownerStatement.comment.indexOf(current), 1);
|
|
126005
|
+
for (const wsComment of workspaceComments) {
|
|
126006
|
+
wsComment.comment.splice(wsComment.comment.indexOf(current), 1);
|
|
126007
|
+
}
|
|
126008
|
+
}
|
|
126009
|
+
current.owner = commented;
|
|
126010
|
+
current.ownerStatement = stmt;
|
|
126011
|
+
comments.push(current);
|
|
126012
|
+
}
|
|
126013
|
+
}
|
|
126014
|
+
if (comments.length) {
|
|
126015
|
+
const wsCommentRefs = [];
|
|
126016
|
+
if (isTopLevelComment(commented)) {
|
|
126017
|
+
let currentWorkspaceComment = [];
|
|
126018
|
+
const localWorkspaceComments = [];
|
|
126019
|
+
comments.forEach((comment, index) => {
|
|
126020
|
+
let beforeStatement = comment.owner && comment.start < comment.owner.getStart();
|
|
126021
|
+
if (comment.kind === CommentKind.MultiLine && beforeStatement) {
|
|
126022
|
+
if (currentWorkspaceComment.length) {
|
|
126023
|
+
localWorkspaceComments.push(currentWorkspaceComment);
|
|
126024
|
+
currentWorkspaceComment = [];
|
|
126025
|
+
}
|
|
126026
|
+
if (index != comments.length - 1) {
|
|
126027
|
+
localWorkspaceComments.push([comment]);
|
|
126028
|
+
return;
|
|
126029
|
+
}
|
|
126030
|
+
}
|
|
126031
|
+
currentWorkspaceComment.push(comment);
|
|
126032
|
+
if (comment.followedByEmptyLine && beforeStatement) {
|
|
126033
|
+
localWorkspaceComments.push(currentWorkspaceComment);
|
|
126034
|
+
currentWorkspaceComment = [];
|
|
126035
|
+
}
|
|
126036
|
+
});
|
|
126037
|
+
comments = currentWorkspaceComment;
|
|
126038
|
+
localWorkspaceComments.forEach(comment => {
|
|
126039
|
+
const refId = getCommentRef();
|
|
126040
|
+
wsCommentRefs.push(refId);
|
|
126041
|
+
workspaceComments.push({ comment, refId });
|
|
126042
|
+
});
|
|
126043
|
+
}
|
|
126044
|
+
// Attach comments to StatementNode
|
|
126045
|
+
if (stmt) {
|
|
126046
|
+
if (wsCommentRefs.length) {
|
|
126047
|
+
if (stmt.data)
|
|
126048
|
+
stmt.data += ";" + wsCommentRefs.join(";");
|
|
126049
|
+
else
|
|
126050
|
+
stmt.data = wsCommentRefs.join(";");
|
|
126051
|
+
}
|
|
126052
|
+
if (comments && comments.length) {
|
|
126053
|
+
if (stmt.comment)
|
|
126054
|
+
stmt.comment = stmt.comment.concat(comments);
|
|
126055
|
+
else
|
|
126056
|
+
stmt.comment = comments;
|
|
126057
|
+
}
|
|
126058
|
+
}
|
|
126059
|
+
}
|
|
126060
|
+
}
|
|
125966
126061
|
function getStatementBlock(n, next, parent, asExpression = false, topLevel = false) {
|
|
125967
126062
|
const node = n;
|
|
125968
126063
|
let stmt;
|
|
@@ -126065,7 +126160,7 @@ ${output}</xml>`;
|
|
|
126065
126160
|
}
|
|
126066
126161
|
}
|
|
126067
126162
|
if (!skipComments) {
|
|
126068
|
-
|
|
126163
|
+
getNodeComments(parent || node, stmt);
|
|
126069
126164
|
}
|
|
126070
126165
|
return stmt;
|
|
126071
126166
|
function getNext() {
|
|
@@ -126074,97 +126169,6 @@ ${output}</xml>`;
|
|
|
126074
126169
|
}
|
|
126075
126170
|
return undefined;
|
|
126076
126171
|
}
|
|
126077
|
-
/**
|
|
126078
|
-
* We split up comments according to the following rules:
|
|
126079
|
-
* 1. If the comment is not top-level:
|
|
126080
|
-
* a. Combine it with all comments for the following statement
|
|
126081
|
-
* b. If there is no following statement in the current block, group it with the previous statement
|
|
126082
|
-
* c. If there are no statements inside the block, group it with the parent block
|
|
126083
|
-
* d. If trailing the same line as the statement, group it with the comments for that statement
|
|
126084
|
-
* 2. If the comment is top-level:
|
|
126085
|
-
* b. If the comment is followed by an empty line, it becomes a workspace comment
|
|
126086
|
-
* c. If the comment is followed by a multi-line comment, it becomes a workspace comment
|
|
126087
|
-
* a. If the comment is a single-line comment, combine it with the next single-line comment
|
|
126088
|
-
* d. If the comment is not followed with an empty line, group it with the next statement or event
|
|
126089
|
-
* e. All other comments are workspace comments
|
|
126090
|
-
*/
|
|
126091
|
-
function getComments(commented) {
|
|
126092
|
-
let comments = [];
|
|
126093
|
-
let current;
|
|
126094
|
-
for (let i = 0; i < commentMap.length; i++) {
|
|
126095
|
-
current = commentMap[i];
|
|
126096
|
-
if (!current.owner && current.start >= commented.pos && current.end <= commented.end) {
|
|
126097
|
-
current.owner = commented;
|
|
126098
|
-
current.ownerStatement = stmt;
|
|
126099
|
-
comments.push(current);
|
|
126100
|
-
}
|
|
126101
|
-
if (current.start > commented.end)
|
|
126102
|
-
break;
|
|
126103
|
-
}
|
|
126104
|
-
if (current && current.isTrailingComment) {
|
|
126105
|
-
const endLine = ts.getLineAndCharacterOfPosition(file, commented.end);
|
|
126106
|
-
const commentLine = ts.getLineAndCharacterOfPosition(file, current.start);
|
|
126107
|
-
if (endLine.line === commentLine.line) {
|
|
126108
|
-
// If the comment is trailing and on the same line as the statement, it probably belongs
|
|
126109
|
-
// to this statement. Remove it from any statement it's already assigned to and any workspace
|
|
126110
|
-
// comments
|
|
126111
|
-
if (current.ownerStatement) {
|
|
126112
|
-
current.ownerStatement.comment.splice(current.ownerStatement.comment.indexOf(current), 1);
|
|
126113
|
-
for (const wsComment of workspaceComments) {
|
|
126114
|
-
wsComment.comment.splice(wsComment.comment.indexOf(current), 1);
|
|
126115
|
-
}
|
|
126116
|
-
}
|
|
126117
|
-
current.owner = commented;
|
|
126118
|
-
current.ownerStatement = stmt;
|
|
126119
|
-
comments.push(current);
|
|
126120
|
-
}
|
|
126121
|
-
}
|
|
126122
|
-
if (comments.length) {
|
|
126123
|
-
const wsCommentRefs = [];
|
|
126124
|
-
if (isTopLevelComment(commented)) {
|
|
126125
|
-
let currentWorkspaceComment = [];
|
|
126126
|
-
const localWorkspaceComments = [];
|
|
126127
|
-
comments.forEach((comment, index) => {
|
|
126128
|
-
let beforeStatement = comment.owner && comment.start < comment.owner.getStart();
|
|
126129
|
-
if (comment.kind === CommentKind.MultiLine && beforeStatement) {
|
|
126130
|
-
if (currentWorkspaceComment.length) {
|
|
126131
|
-
localWorkspaceComments.push(currentWorkspaceComment);
|
|
126132
|
-
currentWorkspaceComment = [];
|
|
126133
|
-
}
|
|
126134
|
-
if (index != comments.length - 1) {
|
|
126135
|
-
localWorkspaceComments.push([comment]);
|
|
126136
|
-
return;
|
|
126137
|
-
}
|
|
126138
|
-
}
|
|
126139
|
-
currentWorkspaceComment.push(comment);
|
|
126140
|
-
if (comment.followedByEmptyLine && beforeStatement) {
|
|
126141
|
-
localWorkspaceComments.push(currentWorkspaceComment);
|
|
126142
|
-
currentWorkspaceComment = [];
|
|
126143
|
-
}
|
|
126144
|
-
});
|
|
126145
|
-
comments = currentWorkspaceComment;
|
|
126146
|
-
localWorkspaceComments.forEach(comment => {
|
|
126147
|
-
const refId = getCommentRef();
|
|
126148
|
-
wsCommentRefs.push(refId);
|
|
126149
|
-
workspaceComments.push({ comment, refId });
|
|
126150
|
-
});
|
|
126151
|
-
}
|
|
126152
|
-
if (stmt) {
|
|
126153
|
-
if (wsCommentRefs.length) {
|
|
126154
|
-
if (stmt.data)
|
|
126155
|
-
stmt.data += ";" + wsCommentRefs.join(";");
|
|
126156
|
-
else
|
|
126157
|
-
stmt.data = wsCommentRefs.join(";");
|
|
126158
|
-
}
|
|
126159
|
-
if (comments && comments.length) {
|
|
126160
|
-
if (stmt.comment)
|
|
126161
|
-
stmt.comment = stmt.comment.concat(comments);
|
|
126162
|
-
else
|
|
126163
|
-
stmt.comment = comments;
|
|
126164
|
-
}
|
|
126165
|
-
}
|
|
126166
|
-
}
|
|
126167
|
-
}
|
|
126168
126172
|
}
|
|
126169
126173
|
function getTypeScriptStatementBlock(node, prefix, err) {
|
|
126170
126174
|
if (options.errorOnGreyBlocks)
|
|
@@ -126934,12 +126938,13 @@ ${output}</xml>`;
|
|
|
126934
126938
|
eventStatements.map(n => getStatementBlock(n, undefined, undefined, false, topLevel)).forEach(emitStatementNode);
|
|
126935
126939
|
if (blockStatements.length) {
|
|
126936
126940
|
// wrap statement in "on start" if top level
|
|
126937
|
-
const
|
|
126938
|
-
const stmt = getStatementBlock(
|
|
126941
|
+
const blockNode = blockStatements.shift();
|
|
126942
|
+
const stmt = getStatementBlock(blockNode, blockStatements, parent, false, topLevel);
|
|
126939
126943
|
if (emitOnStart) {
|
|
126940
126944
|
// Preserve any variable edeclarations that were never used
|
|
126941
|
-
|
|
126942
|
-
let
|
|
126945
|
+
// stmt and blockNode will not yet align if there was an auto-declared variable.
|
|
126946
|
+
let currentStmtNode = stmt;
|
|
126947
|
+
let currentBlockNode = blockNode;
|
|
126943
126948
|
autoDeclarations.forEach(([name, node]) => {
|
|
126944
126949
|
if (varUsages[name] === ReferenceType.InBlocksOnly) {
|
|
126945
126950
|
return;
|
|
@@ -126953,17 +126958,21 @@ ${output}</xml>`;
|
|
|
126953
126958
|
v = getTypeScriptStatementBlock(node, "let ");
|
|
126954
126959
|
}
|
|
126955
126960
|
else {
|
|
126956
|
-
v = getVariableSetOrChangeBlock(
|
|
126961
|
+
v = getVariableSetOrChangeBlock(blockNode, node.name, node.initializer, false, true);
|
|
126957
126962
|
}
|
|
126958
|
-
|
|
126959
|
-
|
|
126960
|
-
|
|
126963
|
+
// Auto-declared variables were not previously inserted into the stmt linked-list.
|
|
126964
|
+
// Insert auto-declared 'v' as the currentStmtNode.
|
|
126965
|
+
v.next = currentStmtNode;
|
|
126966
|
+
currentStmtNode = v;
|
|
126967
|
+
currentBlockNode = node;
|
|
126968
|
+
// Attach to currentStmtNode any associated comments
|
|
126969
|
+
getNodeComments(currentBlockNode.parent, currentStmtNode);
|
|
126961
126970
|
});
|
|
126962
|
-
if (
|
|
126963
|
-
const r = mkStmt(ts.pxtc.ON_START_TYPE,
|
|
126971
|
+
if (currentStmtNode) {
|
|
126972
|
+
const r = mkStmt(ts.pxtc.ON_START_TYPE, currentBlockNode);
|
|
126964
126973
|
r.handlers = [{
|
|
126965
126974
|
name: "HANDLER",
|
|
126966
|
-
statement:
|
|
126975
|
+
statement: currentStmtNode
|
|
126967
126976
|
}];
|
|
126968
126977
|
return r;
|
|
126969
126978
|
}
|
|
@@ -153180,6 +153189,7 @@ var pxsim;
|
|
|
153180
153189
|
}
|
|
153181
153190
|
}
|
|
153182
153191
|
createFrame(url) {
|
|
153192
|
+
var _a;
|
|
153183
153193
|
const wrapper = document.createElement("div");
|
|
153184
153194
|
wrapper.className = `simframe ui embed`;
|
|
153185
153195
|
const frame = document.createElement('iframe');
|
|
@@ -153194,7 +153204,7 @@ var pxsim;
|
|
|
153194
153204
|
frame.frameBorder = "0";
|
|
153195
153205
|
frame.dataset['runid'] = this.runId;
|
|
153196
153206
|
frame.dataset['origin'] = new URL(furl).origin || "*";
|
|
153197
|
-
if (this._runOptions.autofocus)
|
|
153207
|
+
if ((_a = this._runOptions) === null || _a === void 0 ? void 0 : _a.autofocus)
|
|
153198
153208
|
frame.setAttribute("autofocus", "true");
|
|
153199
153209
|
wrapper.appendChild(frame);
|
|
153200
153210
|
const i = document.createElement("i");
|
|
@@ -157722,11 +157732,11 @@ function onlyExts(files, exts) {
|
|
|
157722
157732
|
}
|
|
157723
157733
|
function pxtFileList(pref) {
|
|
157724
157734
|
return nodeutil.allFiles(pref + "webapp/public")
|
|
157725
|
-
.concat(onlyExts(nodeutil.allFiles(pref + "built/web", 1), [".js", ".css"]))
|
|
157726
|
-
.concat(nodeutil.allFiles(pref + "built/web/fonts", 1))
|
|
157727
|
-
.concat(nodeutil.allFiles(pref + "built/web/vs", 4))
|
|
157728
|
-
.concat(nodeutil.allFiles(pref + "built/web/skillmap", 4))
|
|
157729
|
-
.concat(nodeutil.allFiles(pref + "built/web/authcode", 4));
|
|
157735
|
+
.concat(onlyExts(nodeutil.allFiles(pref + "built/web", { maxDepth: 1 }), [".js", ".css"]))
|
|
157736
|
+
.concat(nodeutil.allFiles(pref + "built/web/fonts", { maxDepth: 1 }))
|
|
157737
|
+
.concat(nodeutil.allFiles(pref + "built/web/vs", { maxDepth: 4 }))
|
|
157738
|
+
.concat(nodeutil.allFiles(pref + "built/web/skillmap", { maxDepth: 4 }))
|
|
157739
|
+
.concat(nodeutil.allFiles(pref + "built/web/authcode", { maxDepth: 4 }));
|
|
157730
157740
|
}
|
|
157731
157741
|
function semverCmp(a, b) {
|
|
157732
157742
|
let parse = (s) => {
|
|
@@ -158038,7 +158048,7 @@ function targetFileList() {
|
|
|
158038
158048
|
let lst = onlyExts(nodeutil.allFiles("built"), [".js", ".css", ".json", ".webmanifest"])
|
|
158039
158049
|
.concat(nodeutil.allFiles(path.join(simDir(), "public")));
|
|
158040
158050
|
if (simDir() != "sim")
|
|
158041
|
-
lst = lst.concat(nodeutil.allFiles(path.join("sim", "public"), 5, true));
|
|
158051
|
+
lst = lst.concat(nodeutil.allFiles(path.join("sim", "public"), { maxDepth: 5, allowMissing: true }));
|
|
158042
158052
|
pxt.debug(`target files (on disk): ${lst.join('\r\n ')}`);
|
|
158043
158053
|
return lst;
|
|
158044
158054
|
}
|
|
@@ -158553,7 +158563,7 @@ function forEachBundledPkgAsync(f, includeProjects = false) {
|
|
|
158553
158563
|
let prev = process.cwd();
|
|
158554
158564
|
let folders = pxt.appTarget.bundleddirs;
|
|
158555
158565
|
if (includeProjects) {
|
|
158556
|
-
let projects = nodeutil.allFiles("libs",
|
|
158566
|
+
let projects = nodeutil.allFiles("libs", { maxDepth: 1, includeDirs: true }).filter(f => /prj$/.test(f));
|
|
158557
158567
|
folders = folders.concat(projects);
|
|
158558
158568
|
}
|
|
158559
158569
|
return U.promiseMapAllSeries(folders, (dirname) => {
|
|
@@ -158718,7 +158728,7 @@ function buildEditorExtensionAsync(dirname, optionName) {
|
|
|
158718
158728
|
else
|
|
158719
158729
|
p = buildFolderAsync(dirname, true, dirname);
|
|
158720
158730
|
return p.then(() => {
|
|
158721
|
-
const prepends = nodeutil.allFiles(path.join(dirname, "prepend"), 1, true)
|
|
158731
|
+
const prepends = nodeutil.allFiles(path.join(dirname, "prepend"), { maxDepth: 1, allowMissing: true })
|
|
158722
158732
|
.filter(f => /\.js$/.test(f));
|
|
158723
158733
|
if (prepends && prepends.length) {
|
|
158724
158734
|
const editorjs = path.join("built", dirname + ".js");
|
|
@@ -159319,7 +159329,7 @@ function updateDefaultProjects(cfg) {
|
|
|
159319
159329
|
pxt.BLOCKS_PROJECT_NAME,
|
|
159320
159330
|
pxt.JAVASCRIPT_PROJECT_NAME
|
|
159321
159331
|
];
|
|
159322
|
-
nodeutil.allFiles("libs",
|
|
159332
|
+
nodeutil.allFiles("libs", { maxDepth: 1, includeDirs: true })
|
|
159323
159333
|
.filter((f) => {
|
|
159324
159334
|
return defaultProjects.indexOf(path.basename(f)) !== -1;
|
|
159325
159335
|
})
|
|
@@ -159780,7 +159790,7 @@ function renderDocs(builtPackaged, localDir) {
|
|
|
159780
159790
|
docFolders.push(...nodeutil.getBundledPackagesDocs());
|
|
159781
159791
|
docFolders.push("docs");
|
|
159782
159792
|
for (const docFolder of docFolders) {
|
|
159783
|
-
for (const f of nodeutil.allFiles(docFolder, 8)) {
|
|
159793
|
+
for (const f of nodeutil.allFiles(docFolder, { maxDepth: 8 })) {
|
|
159784
159794
|
pxt.log(`rendering ${f}`);
|
|
159785
159795
|
const pathUnderDocs = f.slice(docFolder.length + 1);
|
|
159786
159796
|
let outputFile = path.join(dst, "docs", pathUnderDocs);
|
|
@@ -161904,7 +161914,7 @@ function buildJResSpritesDirectoryAsync(dir) {
|
|
|
161904
161914
|
return [(v >> 16) & 0xff, (v >> 8) & 0xff, (v >> 0) & 0xff];
|
|
161905
161915
|
});
|
|
161906
161916
|
let ts = `namespace ${metaInfo.star.namespace} {\n`;
|
|
161907
|
-
for (let fn of nodeutil.allFiles(dir, 1)) {
|
|
161917
|
+
for (let fn of nodeutil.allFiles(dir, { maxDepth: 1 })) {
|
|
161908
161918
|
fn = fn.replace(/\\/g, "/");
|
|
161909
161919
|
let m = /(.*\/)(.*)\.png$/i.exec(fn);
|
|
161910
161920
|
if (!m)
|
|
@@ -162479,6 +162489,12 @@ function internalCheckDocsAsync(compileSnippets, re, fix, pycheck) {
|
|
|
162479
162489
|
const docsRoot = nodeutil.targetDir;
|
|
162480
162490
|
const docsTemplate = server.expandDocFileTemplate("docs.html");
|
|
162481
162491
|
pxt.log(`checking docs`);
|
|
162492
|
+
const ignoredFoldersKey = ".checkdocs-ignore";
|
|
162493
|
+
const ignoredFolders = nodeutil.allFiles("docs", { includeHiddenFiles: true })
|
|
162494
|
+
.filter(el => el.endsWith(ignoredFoldersKey))
|
|
162495
|
+
.map(el => path.dirname(path.join(el.substring(4))) + path.sep);
|
|
162496
|
+
if (ignoredFolders.length)
|
|
162497
|
+
pxt.log(`Ignoring folders [${ignoredFolders.join(", ")}]`);
|
|
162482
162498
|
const noTOCs = [];
|
|
162483
162499
|
const todo = [];
|
|
162484
162500
|
let urls = {};
|
|
@@ -162487,12 +162503,12 @@ function internalCheckDocsAsync(compileSnippets, re, fix, pycheck) {
|
|
|
162487
162503
|
// only check each snippet once.
|
|
162488
162504
|
const existingSnippets = {};
|
|
162489
162505
|
let snippets = [];
|
|
162490
|
-
const maxFileSize = checkFileSize(nodeutil.allFiles("docs", 10, true, true, ".ignorelargefiles"));
|
|
162506
|
+
const maxFileSize = checkFileSize(nodeutil.allFiles("docs", { maxDepth: 10, allowMissing: true, includeDirs: true, ignoredFileMarker: ".ignorelargefiles" }));
|
|
162491
162507
|
if (!pxt.appTarget.ignoreDocsErrors
|
|
162492
162508
|
&& maxFileSize > (pxt.appTarget.cloud.maxFileSize || (5000000)))
|
|
162493
162509
|
U.userError(`files too big in docs folder`);
|
|
162494
162510
|
// scan and fix image links
|
|
162495
|
-
nodeutil.allFiles("docs")
|
|
162511
|
+
nodeutil.allFiles("docs", { ignoredFileMarker: ignoredFoldersKey })
|
|
162496
162512
|
.filter(f => /\.md/.test(f))
|
|
162497
162513
|
.forEach(f => {
|
|
162498
162514
|
let md = fs.readFileSync(f, { encoding: "utf8" });
|
|
@@ -162547,6 +162563,9 @@ function internalCheckDocsAsync(compileSnippets, re, fix, pycheck) {
|
|
|
162547
162563
|
urls[url] = isResource
|
|
162548
162564
|
? nodeutil.fileExistsSync(path.join(docsRoot, "docs", url))
|
|
162549
162565
|
: nodeutil.resolveMd(docsRoot, url);
|
|
162566
|
+
const pathedUrl = path.join(url);
|
|
162567
|
+
if (ignoredFolders.some(el => pathedUrl.startsWith(el)))
|
|
162568
|
+
return;
|
|
162550
162569
|
if (!isResource && urls[url])
|
|
162551
162570
|
todo.push(url);
|
|
162552
162571
|
}
|
|
@@ -162564,7 +162583,8 @@ function internalCheckDocsAsync(compileSnippets, re, fix, pycheck) {
|
|
|
162564
162583
|
entry.subitems.forEach(checkTOCEntry);
|
|
162565
162584
|
}
|
|
162566
162585
|
// check over TOCs
|
|
162567
|
-
nodeutil.allFiles("docs", 5
|
|
162586
|
+
nodeutil.allFiles("docs", { maxDepth: 5, ignoredFileMarker: ignoredFoldersKey })
|
|
162587
|
+
.filter(f => /SUMMARY\.md$/.test(f))
|
|
162568
162588
|
.forEach(summaryFile => {
|
|
162569
162589
|
const summaryPath = path.join(path.dirname(summaryFile), 'SUMMARY').replace(/^docs[\/\\]/, '');
|
|
162570
162590
|
pxt.log(`looking for ${summaryPath}`);
|
|
@@ -162602,7 +162622,8 @@ function internalCheckDocsAsync(compileSnippets, re, fix, pycheck) {
|
|
|
162602
162622
|
if (targetDirs) {
|
|
162603
162623
|
targetDirs.forEach(dir => {
|
|
162604
162624
|
pxt.log(`looking for markdown files in ${dir}`);
|
|
162605
|
-
nodeutil.allFiles(path.join("docs", dir), 3
|
|
162625
|
+
nodeutil.allFiles(path.join("docs", dir), { maxDepth: 3, ignoredFileMarker: ".checkdocs-ignore" })
|
|
162626
|
+
.filter(f => mdRegex.test(f))
|
|
162606
162627
|
.forEach(md => {
|
|
162607
162628
|
pushUrl(md.slice(5).replace(mdRegex, ""), true);
|
|
162608
162629
|
});
|
|
@@ -162679,6 +162700,9 @@ function internalCheckDocsAsync(compileSnippets, re, fix, pycheck) {
|
|
|
162679
162700
|
card.otherActions.forEach(a => { if (a.url)
|
|
162680
162701
|
urls.push(a.url); });
|
|
162681
162702
|
for (let url of urls) {
|
|
162703
|
+
const pathedUrl = path.join(url);
|
|
162704
|
+
if (ignoredFolders.some(el => pathedUrl.startsWith(el)))
|
|
162705
|
+
return;
|
|
162682
162706
|
const tutorialMd = nodeutil.resolveMd(docsRoot, url);
|
|
162683
162707
|
if (!tutorialMd) {
|
|
162684
162708
|
pxt.log(`unable to resolve ${url}`);
|
|
@@ -162728,6 +162752,9 @@ function internalCheckDocsAsync(compileSnippets, re, fix, pycheck) {
|
|
|
162728
162752
|
card.otherActions.forEach(a => { if (a.url)
|
|
162729
162753
|
urls.push(a.url); });
|
|
162730
162754
|
for (let url of urls) {
|
|
162755
|
+
const pathedUrl = path.join(url);
|
|
162756
|
+
if (ignoredFolders.some(el => pathedUrl.startsWith(el)))
|
|
162757
|
+
return;
|
|
162731
162758
|
const exMd = nodeutil.resolveMd(docsRoot, url);
|
|
162732
162759
|
if (!exMd) {
|
|
162733
162760
|
pxt.log(`unable to resolve ${url}`);
|
|
@@ -162777,7 +162804,7 @@ function internalCheckDocsAsync(compileSnippets, re, fix, pycheck) {
|
|
|
162777
162804
|
async function upgradeCardsAsync() {
|
|
162778
162805
|
const docsRoot = nodeutil.targetDir;
|
|
162779
162806
|
// markdowns with cards
|
|
162780
|
-
const mds = nodeutil.allFiles(docsRoot, 10
|
|
162807
|
+
const mds = nodeutil.allFiles(docsRoot, { maxDepth: 10 })
|
|
162781
162808
|
.filter(fn => /\.md$/.test(fn))
|
|
162782
162809
|
.map(fn => ({ filename: fn, content: nodeutil.readText(fn) }))
|
|
162783
162810
|
.filter(f => /```codecard/.test(f.content));
|
|
@@ -162805,7 +162832,7 @@ function internalCacheUsedBlocksAsync() {
|
|
|
162805
162832
|
if (targetDirs) {
|
|
162806
162833
|
targetDirs.forEach(dir => {
|
|
162807
162834
|
pxt.log(`looking for tutorial markdown in ${dir}`);
|
|
162808
|
-
nodeutil.allFiles(path.join("docs", dir), 3).filter(f => mdRegex.test(f))
|
|
162835
|
+
nodeutil.allFiles(path.join("docs", dir), { maxDepth: 3 }).filter(f => mdRegex.test(f))
|
|
162809
162836
|
.forEach(md => {
|
|
162810
162837
|
mdPaths.push(md.slice(5).replace(mdRegex, ""));
|
|
162811
162838
|
});
|
|
@@ -162984,7 +163011,7 @@ function webstringsJson() {
|
|
|
162984
163011
|
}
|
|
162985
163012
|
function extractLocStringsAsync(output, dirs) {
|
|
162986
163013
|
let prereqs = [];
|
|
162987
|
-
dirs.forEach(dir => prereqs = prereqs.concat(nodeutil.allFiles(dir, 20)));
|
|
163014
|
+
dirs.forEach(dir => prereqs = prereqs.concat(nodeutil.allFiles(dir, { maxDepth: 20 })));
|
|
162988
163015
|
let errCnt = 0;
|
|
162989
163016
|
let translationStrings = {};
|
|
162990
163017
|
function processLf(filename) {
|