@learnpack/learnpack 2.1.26 → 2.1.27

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. package/README.md +10 -10
  2. package/oclif.manifest.json +1 -1
  3. package/package.json +2 -1
  4. package/src/commands/audit.ts +113 -113
  5. package/src/commands/clean.ts +10 -10
  6. package/src/commands/download.ts +18 -18
  7. package/src/commands/init.ts +39 -39
  8. package/src/commands/login.ts +13 -13
  9. package/src/commands/logout.ts +9 -9
  10. package/src/commands/publish.ts +25 -25
  11. package/src/commands/start.ts +101 -75
  12. package/src/commands/test.ts +34 -34
  13. package/src/managers/config/allowed_files.ts +2 -2
  14. package/src/managers/config/defaults.ts +2 -2
  15. package/src/managers/config/exercise.ts +79 -79
  16. package/src/managers/config/index.ts +145 -145
  17. package/src/managers/file.ts +74 -65
  18. package/src/managers/server/index.ts +32 -31
  19. package/src/managers/server/routes.ts +139 -90
  20. package/src/managers/session.ts +53 -24
  21. package/src/managers/socket.ts +92 -79
  22. package/src/models/action.ts +8 -1
  23. package/src/models/config-manager.ts +2 -2
  24. package/src/models/config.ts +7 -2
  25. package/src/models/exercise-obj.ts +6 -3
  26. package/src/models/plugin-config.ts +2 -2
  27. package/src/models/session.ts +5 -2
  28. package/src/models/socket.ts +12 -6
  29. package/src/models/status.ts +15 -14
  30. package/src/plugin/command/compile.ts +10 -10
  31. package/src/plugin/command/test.ts +14 -14
  32. package/src/plugin/index.ts +5 -5
  33. package/src/plugin/plugin.ts +26 -26
  34. package/src/plugin/utils.ts +23 -23
  35. package/src/utils/BaseCommand.ts +16 -16
  36. package/src/utils/api.ts +143 -91
  37. package/src/utils/audit.ts +93 -96
  38. package/src/utils/exercisesQueue.ts +15 -15
  39. package/src/utils/fileQueue.ts +85 -85
  40. package/src/utils/watcher.ts +14 -14
  41. package/lib/commands/audit.d.ts +0 -6
  42. package/lib/commands/audit.js +0 -342
  43. package/lib/commands/clean.d.ts +0 -8
  44. package/lib/commands/clean.js +0 -25
  45. package/lib/commands/download.d.ts +0 -13
  46. package/lib/commands/download.js +0 -55
  47. package/lib/commands/init.d.ts +0 -9
  48. package/lib/commands/init.js +0 -123
  49. package/lib/commands/login.d.ts +0 -14
  50. package/lib/commands/login.js +0 -37
  51. package/lib/commands/logout.d.ts +0 -14
  52. package/lib/commands/logout.js +0 -37
  53. package/lib/commands/publish.d.ts +0 -14
  54. package/lib/commands/publish.js +0 -82
  55. package/lib/commands/start.d.ts +0 -7
  56. package/lib/commands/start.js +0 -165
  57. package/lib/commands/test.d.ts +0 -6
  58. package/lib/commands/test.js +0 -62
  59. package/lib/index.d.ts +0 -1
  60. package/lib/index.js +0 -4
  61. package/lib/managers/config/allowed_files.d.ts +0 -5
  62. package/lib/managers/config/allowed_files.js +0 -30
  63. package/lib/managers/config/defaults.d.ts +0 -39
  64. package/lib/managers/config/defaults.js +0 -40
  65. package/lib/managers/config/exercise.d.ts +0 -36
  66. package/lib/managers/config/exercise.js +0 -233
  67. package/lib/managers/config/index.d.ts +0 -3
  68. package/lib/managers/config/index.js +0 -320
  69. package/lib/managers/file.d.ts +0 -13
  70. package/lib/managers/file.js +0 -134
  71. package/lib/managers/gitpod.d.ts +0 -3
  72. package/lib/managers/gitpod.js +0 -67
  73. package/lib/managers/server/index.d.ts +0 -6
  74. package/lib/managers/server/index.js +0 -58
  75. package/lib/managers/server/routes.d.ts +0 -4
  76. package/lib/managers/server/routes.js +0 -167
  77. package/lib/managers/session.d.ts +0 -3
  78. package/lib/managers/session.js +0 -104
  79. package/lib/managers/socket.d.ts +0 -3
  80. package/lib/managers/socket.js +0 -164
  81. package/lib/managers/test.d.ts +0 -0
  82. package/lib/managers/test.js +0 -84
  83. package/lib/models/action.d.ts +0 -2
  84. package/lib/models/action.js +0 -2
  85. package/lib/models/audit.d.ts +0 -15
  86. package/lib/models/audit.js +0 -2
  87. package/lib/models/config-manager.d.ts +0 -21
  88. package/lib/models/config-manager.js +0 -2
  89. package/lib/models/config.d.ts +0 -62
  90. package/lib/models/config.js +0 -2
  91. package/lib/models/counter.d.ts +0 -11
  92. package/lib/models/counter.js +0 -2
  93. package/lib/models/errors.d.ts +0 -15
  94. package/lib/models/errors.js +0 -2
  95. package/lib/models/exercise-obj.d.ts +0 -27
  96. package/lib/models/exercise-obj.js +0 -2
  97. package/lib/models/file.d.ts +0 -5
  98. package/lib/models/file.js +0 -2
  99. package/lib/models/findings.d.ts +0 -17
  100. package/lib/models/findings.js +0 -2
  101. package/lib/models/flags.d.ts +0 -10
  102. package/lib/models/flags.js +0 -2
  103. package/lib/models/front-matter.d.ts +0 -11
  104. package/lib/models/front-matter.js +0 -2
  105. package/lib/models/gitpod-data.d.ts +0 -16
  106. package/lib/models/gitpod-data.js +0 -2
  107. package/lib/models/language.d.ts +0 -4
  108. package/lib/models/language.js +0 -2
  109. package/lib/models/package.d.ts +0 -7
  110. package/lib/models/package.js +0 -2
  111. package/lib/models/plugin-config.d.ts +0 -16
  112. package/lib/models/plugin-config.js +0 -2
  113. package/lib/models/session.d.ts +0 -23
  114. package/lib/models/session.js +0 -2
  115. package/lib/models/socket.d.ts +0 -31
  116. package/lib/models/socket.js +0 -2
  117. package/lib/models/status.d.ts +0 -1
  118. package/lib/models/status.js +0 -2
  119. package/lib/models/success-types.d.ts +0 -1
  120. package/lib/models/success-types.js +0 -2
  121. package/lib/plugin/command/compile.d.ts +0 -6
  122. package/lib/plugin/command/compile.js +0 -18
  123. package/lib/plugin/command/test.d.ts +0 -6
  124. package/lib/plugin/command/test.js +0 -25
  125. package/lib/plugin/index.d.ts +0 -27
  126. package/lib/plugin/index.js +0 -7
  127. package/lib/plugin/plugin.d.ts +0 -8
  128. package/lib/plugin/plugin.js +0 -68
  129. package/lib/plugin/utils.d.ts +0 -16
  130. package/lib/plugin/utils.js +0 -58
  131. package/lib/ui/download.d.ts +0 -5
  132. package/lib/ui/download.js +0 -61
  133. package/lib/utils/BaseCommand.d.ts +0 -8
  134. package/lib/utils/BaseCommand.js +0 -41
  135. package/lib/utils/SessionCommand.d.ts +0 -10
  136. package/lib/utils/SessionCommand.js +0 -47
  137. package/lib/utils/api.d.ts +0 -12
  138. package/lib/utils/api.js +0 -173
  139. package/lib/utils/audit.d.ts +0 -16
  140. package/lib/utils/audit.js +0 -302
  141. package/lib/utils/console.d.ts +0 -12
  142. package/lib/utils/console.js +0 -19
  143. package/lib/utils/errors.d.ts +0 -17
  144. package/lib/utils/errors.js +0 -100
  145. package/lib/utils/exercisesQueue.d.ts +0 -9
  146. package/lib/utils/exercisesQueue.js +0 -38
  147. package/lib/utils/fileQueue.d.ts +0 -40
  148. package/lib/utils/fileQueue.js +0 -168
  149. package/lib/utils/misc.d.ts +0 -1
  150. package/lib/utils/misc.js +0 -23
  151. package/lib/utils/validators.d.ts +0 -5
  152. package/lib/utils/validators.js +0 -17
  153. package/lib/utils/watcher.d.ts +0 -2
  154. package/lib/utils/watcher.js +0 -23
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const console_1 = require("../utils/console");
4
- const SessionCommand_1 = require("../utils/SessionCommand");
5
- const socket_1 = require("../managers/socket");
6
- const server_1 = require("../managers/server");
7
- const exercisesQueue_1 = require("../utils/exercisesQueue");
8
- class TestCommand extends SessionCommand_1.default {
9
- async init() {
10
- const { flags } = this.parse(TestCommand);
11
- await this.initSession(flags);
12
- }
13
- async run() {
14
- var _a, _b, _c;
15
- const { args: { exerciseSlug }, } = this.parse(TestCommand);
16
- // Build exercises index
17
- (_a = this.configManager) === null || _a === void 0 ? void 0 : _a.buildIndex();
18
- let exercises = [];
19
- // test all exercises
20
- !exerciseSlug ?
21
- (exercises = (_b = this.configManager) === null || _b === void 0 ? void 0 : _b.getAllExercises()) :
22
- (exercises = [this.configManager.getExercise(exerciseSlug)]);
23
- const exercisesQueue = new exercisesQueue_1.default(exercises);
24
- const configObject = (_c = this.configManager) === null || _c === void 0 ? void 0 : _c.get();
25
- let hasFailed = false;
26
- let failedTestsCount = 0;
27
- let successTestsCount = 0;
28
- const testsToRunCount = exercisesQueue.size();
29
- configObject.config.testingFinishedCallback = ({ result }) => {
30
- if (result === "failed") {
31
- hasFailed = true;
32
- failedTestsCount++;
33
- }
34
- else {
35
- successTestsCount++;
36
- }
37
- if (exercisesQueue.isEmpty()) {
38
- console_1.default.info(`${testsToRunCount} test${testsToRunCount > 1 ? "s" : ""} runned`);
39
- console_1.default.success(`${successTestsCount} test${successTestsCount > 1 ? "s" : ""} passed`);
40
- console_1.default.error(`${failedTestsCount} test${failedTestsCount > 1 ? "s" : ""} failed`);
41
- process.exit(hasFailed ? 1 : 0);
42
- }
43
- else {
44
- exercisesQueue.pop().test(this.config, config, socket_1.default);
45
- }
46
- };
47
- const config = configObject === null || configObject === void 0 ? void 0 : configObject.config;
48
- const server = await server_1.default(configObject, this.configManager, true);
49
- socket_1.default.start(config, server, true);
50
- exercisesQueue.pop().test(this.config, config, socket_1.default);
51
- }
52
- }
53
- TestCommand.description = `Test exercises`;
54
- TestCommand.args = [
55
- {
56
- name: "exerciseSlug",
57
- required: false,
58
- description: "The name of the exercise to test",
59
- hidden: false,
60
- },
61
- ];
62
- exports.default = TestCommand;
package/lib/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from '@oclif/command';
package/lib/index.js DELETED
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("@oclif/command"), exports);
@@ -1,5 +0,0 @@
1
- declare const extensions: {
2
- extensions: string[];
3
- names: string[];
4
- };
5
- export default extensions;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const extensions = {
4
- extensions: [
5
- "py",
6
- "java",
7
- "py",
8
- "ruby",
9
- "html",
10
- "css",
11
- "htm",
12
- "php",
13
- "js",
14
- "jsx",
15
- "ts",
16
- "sh",
17
- "bash",
18
- "json",
19
- "yml",
20
- "yaml",
21
- "csv",
22
- "xml",
23
- "txt",
24
- "text",
25
- "markdown",
26
- "readme",
27
- ],
28
- names: ["package.json", "package-lock.json"],
29
- };
30
- exports.default = extensions;
@@ -1,39 +0,0 @@
1
- declare const _default: {
2
- config: {
3
- port: number;
4
- editor: {
5
- mode: null;
6
- agent: null;
7
- version: null;
8
- };
9
- dirPath: string;
10
- configPath: string;
11
- outputPath: string;
12
- publicPath: string;
13
- publicUrl: null;
14
- contact: string;
15
- language: string;
16
- autoPlay: boolean;
17
- projectType: string;
18
- grading: string;
19
- exercisesPath: string;
20
- webpackTemplate: null;
21
- disableGrading: boolean;
22
- disabledActions: never[];
23
- actions: never[];
24
- entries: {
25
- html: string;
26
- vanillajs: string;
27
- react: string;
28
- node: string;
29
- python3: string;
30
- java: string;
31
- };
32
- };
33
- address: string;
34
- currentExercise: null;
35
- exercises: never[];
36
- bugsLink: null;
37
- videoSolutions: boolean;
38
- };
39
- export default _default;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = {
4
- config: {
5
- port: 3000,
6
- editor: {
7
- mode: null,
8
- agent: null,
9
- version: null,
10
- },
11
- dirPath: "./.learn",
12
- configPath: "./learn.json",
13
- outputPath: "./.learn/dist",
14
- publicPath: "/preview",
15
- publicUrl: null,
16
- contact: "https://github.com/learnpack/learnpack/issues/new",
17
- language: "auto",
18
- autoPlay: true,
19
- projectType: "tutorial",
20
- grading: "isolated",
21
- exercisesPath: "./",
22
- webpackTemplate: null,
23
- disableGrading: false,
24
- disabledActions: [],
25
- actions: [],
26
- entries: {
27
- html: "index.html",
28
- vanillajs: "index.js",
29
- react: "app.jsx",
30
- node: "app.js",
31
- python3: "app.py",
32
- java: "app.java",
33
- },
34
- },
35
- address: "http://localhost",
36
- currentExercise: null,
37
- exercises: [],
38
- bugsLink: null,
39
- videoSolutions: false,
40
- };
@@ -1,36 +0,0 @@
1
- import { IConfigObj } from "../../models/config";
2
- import { IFile } from "../../models/file";
3
- import { IExercise } from "../../models/exercise-obj";
4
- export declare const exercise: (path: string, position: number, configObject: IConfigObj) => IExercise;
5
- export declare const validateExerciseDirectoryName: (str: string) => boolean;
6
- export declare const isCodable: (str: string) => boolean;
7
- export declare const shouldBeVisible: (file: IFile) => boolean;
8
- export declare const isDirectory: (source: string) => boolean;
9
- export declare const detect: (configObject: IConfigObj | undefined, files: Array<string>) => {
10
- language: string;
11
- entry: string | undefined;
12
- } | {
13
- language: null;
14
- entry: null;
15
- } | undefined;
16
- export declare const filterFiles: (files: Array<string>, basePath?: string) => {
17
- path: string;
18
- name: string;
19
- hidden: boolean;
20
- }[];
21
- declare const _default: {
22
- exercise: (path: string, position: number, configObject: IConfigObj) => IExercise;
23
- detect: (configObject: IConfigObj | undefined, files: string[]) => {
24
- language: string;
25
- entry: string | undefined;
26
- } | {
27
- language: null;
28
- entry: null;
29
- } | undefined;
30
- filterFiles: (files: string[], basePath?: string) => {
31
- path: string;
32
- name: string;
33
- hidden: boolean;
34
- }[];
35
- };
36
- export default _default;
@@ -1,233 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterFiles = exports.detect = exports.isDirectory = exports.shouldBeVisible = exports.isCodable = exports.validateExerciseDirectoryName = exports.exercise = void 0;
4
- const p = require("path");
5
- // import frontMatter from 'front-matter'
6
- const fs = require("fs");
7
- const console_1 = require("../../utils/console");
8
- const allowed_files_1 = require("./allowed_files");
9
- // eslint-disable-next-line
10
- const frontMatter = require("front-matter");
11
- exports.exercise = (path, position, configObject) => {
12
- const { config, exercises } = configObject;
13
- let slug = p.basename(path);
14
- if (!exports.validateExerciseDirectoryName(slug)) {
15
- console_1.default.error(`Exercise directory ${slug} has an invalid name, it has to start with two or three digits followed by words separated by underscors or hyphen (no white spaces). e.g: 01.12-hello-world`);
16
- }
17
- // get all the files
18
- const files = fs.readdirSync(path);
19
- /**
20
- * build the translation array like:
21
- {
22
- "us": "path/to/Readme.md",
23
- "es": "path/to/Readme.es.md"
24
- }
25
- */
26
- const translations = {};
27
- for (const file of files.filter(file => file.toLowerCase().includes("readme"))) {
28
- const parts = file.split(".");
29
- if (parts.length === 3)
30
- translations[parts[1]] = file;
31
- else
32
- translations.us = file;
33
- }
34
- // if the slug is a dot, it means there is not "exercises" folder, and its just a single README.md
35
- if (slug === ".")
36
- slug = "default-index";
37
- const detected = exports.detect(configObject, files);
38
- const exerciseObj = {
39
- position,
40
- path,
41
- slug,
42
- translations,
43
- language: detected === null || detected === void 0 ? void 0 : detected.language,
44
- entry: (detected === null || detected === void 0 ? void 0 : detected.entry) ? path + "/" + detected.entry : null,
45
- title: slug || "Exercise",
46
- graded: files.some((file) => file.toLowerCase().startsWith("test.") ||
47
- file.toLowerCase().startsWith("tests.")),
48
- files: exports.filterFiles(files, path),
49
- // if the exercises was on the config before I may keep the status done
50
- done: Array.isArray(exercises) &&
51
- typeof exercises[position] !== "undefined" &&
52
- path.slice(Math.max(0, path.indexOf("exercises/") + 10)) ===
53
- exercises[position].slug ?
54
- exercises[position].done :
55
- false,
56
- getReadme: function (lang = null) {
57
- if (lang === "us")
58
- lang = null; // <-- english is default, no need to append it to the file name
59
- if (!fs.existsSync(`${this.path}/README${lang ? "." + lang : ""}.md`)) {
60
- console_1.default.error(`Language ${lang} not found for exercise ${slug}, switching to default language`);
61
- if (lang)
62
- lang = null;
63
- if (!fs.existsSync(`${this.path}/README${lang ? "." + lang : ""}.md`))
64
- throw new Error("Readme file not found for exercise: " + this.path + "/README.md");
65
- }
66
- const content = fs.readFileSync(`${this.path}/README${lang ? "." + lang : ""}.md`, "utf8");
67
- const attr = frontMatter(content);
68
- return attr;
69
- },
70
- getFile: function (name) {
71
- const file = this.files.find((f) => f.name === name);
72
- if (!file || !fs.existsSync(file.path)) {
73
- throw new Error(`File not found: + ${file === null || file === void 0 ? void 0 : file.path}`);
74
- }
75
- else if (fs.lstatSync(file.path).isDirectory()) {
76
- return ("Error: This is not a file to be read, but a directory: " + file.path);
77
- }
78
- // get file content
79
- const content = fs.readFileSync(file.path);
80
- // create reset folder
81
- if (!fs.existsSync(`${config === null || config === void 0 ? void 0 : config.dirPath}/resets`))
82
- fs.mkdirSync(`${config === null || config === void 0 ? void 0 : config.dirPath}/resets`);
83
- if (!fs.existsSync(`${config === null || config === void 0 ? void 0 : config.dirPath}/resets/` + this.slug)) {
84
- fs.mkdirSync(`${config === null || config === void 0 ? void 0 : config.dirPath}/resets/` + this.slug);
85
- for (const _file of this.files) {
86
- const fileContent = fs.readFileSync(_file.path);
87
- if (!fs.existsSync(`${config === null || config === void 0 ? void 0 : config.dirPath}/resets/${this.slug}/${_file.name}`)) {
88
- fs.writeFileSync(`${config === null || config === void 0 ? void 0 : config.dirPath}/resets/${this.slug}/${_file.name}`, fileContent);
89
- }
90
- }
91
- }
92
- return content;
93
- },
94
- saveFile: function (name, content) {
95
- const file = this.files.find((f) => f.name === name);
96
- if (file) {
97
- if (!fs.existsSync(file.path)) {
98
- throw new Error("File not found: " + file.path);
99
- }
100
- return fs.writeFileSync(file.path, content, "utf8");
101
- }
102
- },
103
- getTestReport: function () {
104
- var _a;
105
- const _path = `${(_a = configObject === null || configObject === void 0 ? void 0 : configObject.confPath) === null || _a === void 0 ? void 0 : _a.base}/reports/${this.slug}.json`;
106
- if (!fs.existsSync(_path))
107
- return {};
108
- const content = fs.readFileSync(_path);
109
- const data = JSON.parse(`${content}`);
110
- return data;
111
- },
112
- };
113
- return exerciseObj;
114
- };
115
- exports.validateExerciseDirectoryName = (str) => {
116
- if (str === "./")
117
- return true;
118
- // TODO: Add nameValidationREgex from the config
119
- const regex = /^(\d{2,3}(\.\d{1,2})?-([\dA-Za-z]+(-|_)?)+)$/;
120
- return regex.test(str);
121
- };
122
- exports.isCodable = (str) => {
123
- const extension = p.extname(str);
124
- return allowed_files_1.default.extensions.includes(extension.slice(1).toLowerCase());
125
- };
126
- const isNotConfiguration = (str) => {
127
- return !allowed_files_1.default.names.includes(str);
128
- };
129
- exports.shouldBeVisible = function (file) {
130
- return (
131
- // doest not have "test." on their name
132
- !file.name.toLocaleLowerCase().includes("test.") &&
133
- !file.name.toLocaleLowerCase().includes("tests.") &&
134
- !file.name.toLocaleLowerCase().includes(".hide.") &&
135
- // ignore hidden files
136
- file.name.charAt(0) !== "." &&
137
- // ignore learn.json and bc.json
138
- !file.name.toLocaleLowerCase().includes("learn.json") &&
139
- !file.name.toLocaleLowerCase().includes("bc.json") &&
140
- // ignore images, videos, vectors, etc.
141
- exports.isCodable(file.name) &&
142
- isNotConfiguration(file.name) &&
143
- // readme's and directories
144
- !file.name.toLowerCase().includes("readme.") &&
145
- !exports.isDirectory(file.path) &&
146
- file.name.charAt(0) !== "_");
147
- };
148
- exports.isDirectory = (source) => {
149
- // if(path.basename(source) === path.basename(config.dirPath)) return false
150
- return fs.lstatSync(source).isDirectory();
151
- };
152
- exports.detect = (configObject, files) => {
153
- if (!configObject) {
154
- return;
155
- }
156
- const { config } = configObject;
157
- if (!config)
158
- throw new Error("No configuration found during the engine detection");
159
- if (!config.entries)
160
- throw new Error("No configuration found for entries, please add a 'entries' object with the default file name for your exercise entry file that is going to be used while compiling, for example: index.html for html, app.py for python3, etc.");
161
- // A language was found on the config object, but this language will only be used as last resort, learnpack will try to guess each exercise language independently based on file extension (js, jsx, html, etc.)
162
- let hasFiles = files.filter(f => f.includes(".py"));
163
- if (hasFiles.length > 0)
164
- return {
165
- language: "python3",
166
- entry: hasFiles.find(f => config.entries.python3 === f),
167
- };
168
- hasFiles = files.filter(f => f.includes(".java"));
169
- if (hasFiles.length > 0)
170
- return {
171
- language: "java",
172
- entry: hasFiles.find(f => config.entries.java === f),
173
- };
174
- hasFiles = files.filter(f => f.includes(".jsx"));
175
- if (hasFiles.length > 0)
176
- return {
177
- language: "react",
178
- entry: hasFiles.find(f => config.entries.react === f),
179
- };
180
- const hasHTML = files.filter(f => f.includes("index.html"));
181
- const hasIndexJS = files.find(f => f.includes("index.js"));
182
- const hasJS = files.filter(f => f.includes(".js"));
183
- // angular, vue, vanillajs needs to have at least 2 files (html,css,js),
184
- // the test.js and the entry file in js
185
- // if not its just another HTML
186
- if (hasIndexJS && hasHTML.length > 0)
187
- return {
188
- language: "vanillajs",
189
- entry: hasIndexJS,
190
- };
191
- if (hasHTML.length > 0)
192
- return {
193
- language: "html",
194
- entry: hasHTML.find(f => config.entries.html === f),
195
- };
196
- if (hasJS.length > 0)
197
- return {
198
- language: "node",
199
- entry: hasJS.find(f => config.entries.node === f),
200
- };
201
- return {
202
- language: null,
203
- entry: null,
204
- };
205
- };
206
- exports.filterFiles = (files, basePath = ".") => files
207
- .map((ex) => ({
208
- path: basePath + "/" + ex,
209
- name: ex,
210
- hidden: !exports.shouldBeVisible({
211
- name: ex,
212
- path: basePath + "/" + ex,
213
- }),
214
- }))
215
- .sort((f1, f2) => {
216
- const score = {
217
- // sorting priority
218
- "index.html": 1,
219
- "styles.css": 2,
220
- "styles.scss": 2,
221
- "style.css": 2,
222
- "style.scss": 2,
223
- "index.css": 2,
224
- "index.scss": 2,
225
- "index.js": 3,
226
- };
227
- return score[f1.name] < score[f2.name] ? -1 : 1;
228
- });
229
- exports.default = {
230
- exercise: exports.exercise,
231
- detect: exports.detect,
232
- filterFiles: exports.filterFiles,
233
- };
@@ -1,3 +0,0 @@
1
- import { IConfigManagerAttributes, IConfigManager } from "../../models/config-manager";
2
- declare const _default: ({ grading, mode, disableGrading, version, }: IConfigManagerAttributes) => Promise<IConfigManager>;
3
- export default _default;