@boristype/bt-cli 0.1.0-alpha.0
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/LICENSE +21 -0
- package/README.md +66 -0
- package/build/builder/config.js +88 -0
- package/build/cli/commands/artifact.js +14 -0
- package/build/cli/commands/build.js +25 -0
- package/build/cli/commands/dev.js +190 -0
- package/build/cli/commands/index.js +18 -0
- package/build/cli/commands/init.js +15 -0
- package/build/cli/commands/link.js +18 -0
- package/build/cli/commands/push.js +28 -0
- package/build/cli/index.js +14 -0
- package/build/cli/types.js +2 -0
- package/build/core/artifacting/context.js +54 -0
- package/build/core/artifacting/index.js +37 -0
- package/build/core/artifacting/stages/index.js +10 -0
- package/build/core/artifacting/stages/main-archive.js +72 -0
- package/build/core/artifacting/stages/validate.js +70 -0
- package/build/core/artifacting/types.js +6 -0
- package/build/core/artifacting/utils/index.js +10 -0
- package/build/core/artifacting/utils/zip.js +94 -0
- package/build/core/babel.js +96 -0
- package/build/core/btconfig.types.js +6 -0
- package/build/core/build.js +280 -0
- package/build/core/building/compile-mode.js +146 -0
- package/build/core/building/compiler.js +281 -0
- package/build/core/building/coordinator.js +71 -0
- package/build/core/building/files.js +290 -0
- package/build/core/building/index.js +102 -0
- package/build/core/building/output.js +92 -0
- package/build/core/building/transformers.js +110 -0
- package/build/core/building/types.js +19 -0
- package/build/core/config.js +157 -0
- package/build/core/dependencies.js +223 -0
- package/build/core/linking/cache.js +260 -0
- package/build/core/linking/context.js +149 -0
- package/build/core/linking/dependencies.js +240 -0
- package/build/core/linking/executables.js +61 -0
- package/build/core/linking/generators/api-ext.js +57 -0
- package/build/core/linking/generators/component.js +83 -0
- package/build/core/linking/generators/filemap.js +53 -0
- package/build/core/linking/generators/index.js +21 -0
- package/build/core/linking/generators/init-xml.js +37 -0
- package/build/core/linking/generators/package-json.js +50 -0
- package/build/core/linking/index.js +213 -0
- package/build/core/linking/linkers/component.js +175 -0
- package/build/core/linking/linkers/index.js +69 -0
- package/build/core/linking/linkers/standalone.js +144 -0
- package/build/core/linking/linkers/system.js +86 -0
- package/build/core/linking/parsers.js +278 -0
- package/build/core/linking/types.js +6 -0
- package/build/core/linking/utils/copy.js +101 -0
- package/build/core/linking/utils/index.js +26 -0
- package/build/core/linking/utils/node-modules.js +226 -0
- package/build/core/linking/utils/package-type.js +101 -0
- package/build/core/linking/utils/url.js +73 -0
- package/build/core/linking/utils/write.js +91 -0
- package/build/core/logger.js +10 -0
- package/build/core/pushing/config.js +90 -0
- package/build/core/pushing/index.js +96 -0
- package/build/core/pushing/init-scripts.js +173 -0
- package/build/core/pushing/queue.js +95 -0
- package/build/core/pushing/reinit.js +61 -0
- package/build/core/pushing/session.js +167 -0
- package/build/core/pushing/types.js +6 -0
- package/build/core/pushing/upload.js +35 -0
- package/build/core/tsconfig.js +78 -0
- package/build/core/utils/index.js +17 -0
- package/build/core/utils/logger.js +46 -0
- package/build/core/utils/properties.js +81 -0
- package/build/core/utils/xml.js +44 -0
- package/build/core/utils.js +59 -0
- package/build/index.js +76 -0
- package/build/plugins/destructuring.js +83 -0
- package/build/plugins/forOfToForIn.js +14 -0
- package/build/plugins/loopHoistVariables.js +160 -0
- package/build/plugins/precedence.js +172 -0
- package/build/plugins/removeImportExport.js +42 -0
- package/build/plugins/replaceDollar.js +16 -0
- package/build/plugins/spreadArray.js +42 -0
- package/build/plugins/spreadObject.js +91 -0
- package/build/transformers/arrayFunctional.js +467 -0
- package/build/transformers/arrayGeneral.js +222 -0
- package/build/transformers/blockScoping.js +212 -0
- package/build/transformers/destructuring.js +133 -0
- package/build/transformers/dirname.js +79 -0
- package/build/transformers/enumsToObjects.js +25 -0
- package/build/transformers/execObj.js +220 -0
- package/build/transformers/forOfToForIn.js +45 -0
- package/build/transformers/funcSemantic.js +113 -0
- package/build/transformers/functions.js +270 -0
- package/build/transformers/globalCache.js +34 -0
- package/build/transformers/loopHoistVariables.js +352 -0
- package/build/transformers/math.js +39 -0
- package/build/transformers/namespaces.js +22 -0
- package/build/transformers/numericSeparator.js +46 -0
- package/build/transformers/objectProperties.js +54 -0
- package/build/transformers/precedence.js +192 -0
- package/build/transformers/propSemantic.js +467 -0
- package/build/transformers/remodule.js +620 -0
- package/build/transformers/removeImportExport.js +135 -0
- package/build/transformers/replaceDollar.js +46 -0
- package/build/transformers/shorthandProperties.js +34 -0
- package/build/transformers/spreadArray.js +68 -0
- package/build/transformers/spreadObject.js +134 -0
- package/build/transformers/string.js +138 -0
- package/build/transformers/templateLiterals.js +104 -0
- package/build/transformers/tocodelibrary.js +178 -0
- package/build/transformers/utils.js +202 -0
- package/build/wshcm/client.js +193 -0
- package/build/wshcm/evaluator.js +111 -0
- package/build/wshcm/exceptions.js +25 -0
- package/build/wshcm/index.js +20 -0
- package/build/wshcm/soap-utils.js +228 -0
- package/build/wshcm/types.js +2 -0
- package/build/wshcm/uploader.js +320 -0
- package/package.json +51 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getTSConfig = getTSConfig;
|
|
7
|
+
exports.generateDefaultTSConfig = generateDefaultTSConfig;
|
|
8
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
9
|
+
const logger_1 = require("./logger");
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
|
+
const node_fs_1 = require("node:fs");
|
|
12
|
+
function getTSConfig(cwd, project = 'tsconfig.json', options) {
|
|
13
|
+
const tsconfigPath = typescript_1.default.findConfigFile(cwd, typescript_1.default.sys.fileExists, project);
|
|
14
|
+
if (!tsconfigPath) {
|
|
15
|
+
logger_1.logger.error(`There is no any configuration files at "${cwd}". Execute npx tsc -init to create a new one.`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
const { config, error } = typescript_1.default.readConfigFile(tsconfigPath, typescript_1.default.sys.readFile);
|
|
19
|
+
if (error) {
|
|
20
|
+
logger_1.logger.error(error.messageText.toString());
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
const configFileContent = typescript_1.default.parseJsonConfigFileContent(config, typescript_1.default.sys, './');
|
|
24
|
+
if (configFileContent.errors.length > 0) {
|
|
25
|
+
configFileContent.errors.forEach(x => {
|
|
26
|
+
logger_1.logger.error(x.messageText.toString());
|
|
27
|
+
});
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
return configFileContent;
|
|
31
|
+
}
|
|
32
|
+
function generateDefaultTSConfig(cwd = process.cwd()) {
|
|
33
|
+
const tsconfigContent = `{
|
|
34
|
+
"compilerOptions": {
|
|
35
|
+
"target": "esnext",
|
|
36
|
+
"module": "esnext",
|
|
37
|
+
"moduleResolution": "Bundler",
|
|
38
|
+
"rootDir": "./src/",
|
|
39
|
+
"outDir": "./build/",
|
|
40
|
+
"strict": true,
|
|
41
|
+
"noImplicitAny": true,
|
|
42
|
+
"allowJs": true,
|
|
43
|
+
"strictNullChecks": true,
|
|
44
|
+
"strictFunctionTypes": true,
|
|
45
|
+
"strictBindCallApply": true,
|
|
46
|
+
"noImplicitThis": true,
|
|
47
|
+
"alwaysStrict": true,
|
|
48
|
+
"noLib": true,
|
|
49
|
+
"typeRoots": [
|
|
50
|
+
"node_modules/@boristype/types/lib",
|
|
51
|
+
"node_modules/@boristype/types/lib/xml"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"include": [
|
|
55
|
+
"src/**/*"
|
|
56
|
+
],
|
|
57
|
+
"exclude": [
|
|
58
|
+
"node_modules"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
const tsconfigPath = (0, node_path_1.join)(cwd, 'tsconfig.json');
|
|
63
|
+
if ((0, node_fs_1.existsSync)(tsconfigPath)) {
|
|
64
|
+
logger_1.logger.warning('⚠️ tsconfig.json already exists. Skipping generation.');
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
(0, node_fs_1.writeFileSync)(tsconfigPath, tsconfigContent, 'utf8');
|
|
69
|
+
logger_1.logger.success('Created a new tsconfig.json');
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
// A 'tsconfig.json' file is already defined at:
|
|
74
|
+
// logger.error('❌ Failed to create tsconfig.json:', error);
|
|
75
|
+
logger_1.logger.error('❌ Failed to create tsconfig.json');
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Общие утилиты btc
|
|
4
|
+
*
|
|
5
|
+
* @module core/utils
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.xmlParser = exports.xmlBuilderKeepEmpty = exports.xmlBuilder = exports.parsePropertiesFile = exports.parseProperties = exports.logger = void 0;
|
|
9
|
+
var logger_js_1 = require("./logger.js");
|
|
10
|
+
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return logger_js_1.logger; } });
|
|
11
|
+
var properties_js_1 = require("./properties.js");
|
|
12
|
+
Object.defineProperty(exports, "parseProperties", { enumerable: true, get: function () { return properties_js_1.parseProperties; } });
|
|
13
|
+
Object.defineProperty(exports, "parsePropertiesFile", { enumerable: true, get: function () { return properties_js_1.parsePropertiesFile; } });
|
|
14
|
+
var xml_js_1 = require("./xml.js");
|
|
15
|
+
Object.defineProperty(exports, "xmlBuilder", { enumerable: true, get: function () { return xml_js_1.xmlBuilder; } });
|
|
16
|
+
Object.defineProperty(exports, "xmlBuilderKeepEmpty", { enumerable: true, get: function () { return xml_js_1.xmlBuilderKeepEmpty; } });
|
|
17
|
+
Object.defineProperty(exports, "xmlParser", { enumerable: true, get: function () { return xml_js_1.xmlParser; } });
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Logger — цветной вывод в консоль
|
|
4
|
+
*
|
|
5
|
+
* Использует `util.styleText` из Node.js 21.7+ для раскраски.
|
|
6
|
+
* На более старых версиях выводит plain text.
|
|
7
|
+
*
|
|
8
|
+
* @module core/utils/logger
|
|
9
|
+
*/
|
|
10
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.logger = void 0;
|
|
15
|
+
const node_util_1 = __importDefault(require("node:util"));
|
|
16
|
+
class Logger {
|
|
17
|
+
#styleText = (_color, message) => message;
|
|
18
|
+
constructor() {
|
|
19
|
+
this.#reimplementStyleText();
|
|
20
|
+
}
|
|
21
|
+
/** Вывод ошибки (красный) */
|
|
22
|
+
error(message) {
|
|
23
|
+
console.error(this.#styleText('red', message));
|
|
24
|
+
}
|
|
25
|
+
/** Вывод успешного результата (зелёный) */
|
|
26
|
+
success(message) {
|
|
27
|
+
console.log(this.#styleText('greenBright', message));
|
|
28
|
+
}
|
|
29
|
+
/** Вывод предупреждения (жёлтый) */
|
|
30
|
+
warning(message) {
|
|
31
|
+
console.warn(this.#styleText('yellow', message));
|
|
32
|
+
}
|
|
33
|
+
/** Вывод информации (голубой) */
|
|
34
|
+
info(message) {
|
|
35
|
+
console.log(this.#styleText('cyan', message));
|
|
36
|
+
}
|
|
37
|
+
#reimplementStyleText() {
|
|
38
|
+
const nodeVersionArray = process.versions.node.split('.');
|
|
39
|
+
if (Number(nodeVersionArray[0]) > 21 ||
|
|
40
|
+
(Number(nodeVersionArray[0]) === 21 && Number(nodeVersionArray[1]) > 7)) {
|
|
41
|
+
this.#styleText = node_util_1.default.styleText;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** Глобальный синглтон логгера */
|
|
46
|
+
exports.logger = new Logger();
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Generic .properties file parser
|
|
4
|
+
*
|
|
5
|
+
* Формат: key=value, одна пара на строку.
|
|
6
|
+
* Строки начинающиеся с `#` — комментарии.
|
|
7
|
+
* Пустые строки игнорируются.
|
|
8
|
+
*
|
|
9
|
+
* @module core/utils/properties
|
|
10
|
+
*/
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
+
}) : function(o, v) {
|
|
25
|
+
o["default"] = v;
|
|
26
|
+
});
|
|
27
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
28
|
+
var ownKeys = function(o) {
|
|
29
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30
|
+
var ar = [];
|
|
31
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32
|
+
return ar;
|
|
33
|
+
};
|
|
34
|
+
return ownKeys(o);
|
|
35
|
+
};
|
|
36
|
+
return function (mod) {
|
|
37
|
+
if (mod && mod.__esModule) return mod;
|
|
38
|
+
var result = {};
|
|
39
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
40
|
+
__setModuleDefault(result, mod);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
})();
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.parseProperties = parseProperties;
|
|
46
|
+
exports.parsePropertiesFile = parsePropertiesFile;
|
|
47
|
+
const fs = __importStar(require("node:fs"));
|
|
48
|
+
/**
|
|
49
|
+
* Парсит содержимое в формате `.properties` (key=value).
|
|
50
|
+
*
|
|
51
|
+
* @param content - текстовое содержимое файла
|
|
52
|
+
* @returns объект ключ-значение
|
|
53
|
+
*/
|
|
54
|
+
function parseProperties(content) {
|
|
55
|
+
const lines = content.split(/\r?\n/);
|
|
56
|
+
const result = {};
|
|
57
|
+
for (const line of lines) {
|
|
58
|
+
const trimmedLine = line.trim();
|
|
59
|
+
if (trimmedLine === '' || trimmedLine.startsWith('#')) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const [key, value] = trimmedLine.split('=', 2);
|
|
63
|
+
if (key && value !== undefined) {
|
|
64
|
+
result[key.trim()] = value.trim();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Читает и парсит `.properties` файл.
|
|
71
|
+
*
|
|
72
|
+
* @param filePath - абсолютный путь к файлу
|
|
73
|
+
* @returns объект ключ-значение, или пустой объект если файл не существует
|
|
74
|
+
*/
|
|
75
|
+
function parsePropertiesFile(filePath) {
|
|
76
|
+
if (!fs.existsSync(filePath) || !fs.lstatSync(filePath).isFile()) {
|
|
77
|
+
return {};
|
|
78
|
+
}
|
|
79
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
80
|
+
return parseProperties(content);
|
|
81
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Общие XML builder/parser пресеты
|
|
4
|
+
*
|
|
5
|
+
* Централизованные экземпляры XMLBuilder/XMLParser для использования
|
|
6
|
+
* в linking-генераторах, building/output и других модулях.
|
|
7
|
+
*
|
|
8
|
+
* @module core/utils/xml
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.xmlParser = exports.xmlBuilderKeepEmpty = exports.xmlBuilder = void 0;
|
|
12
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
13
|
+
/** Общие опции для всех XML builder'ов */
|
|
14
|
+
const BASE_BUILDER_OPTIONS = {
|
|
15
|
+
ignoreAttributes: false,
|
|
16
|
+
attributeNamePrefix: '@_',
|
|
17
|
+
format: true,
|
|
18
|
+
indentBy: '\t',
|
|
19
|
+
processEntities: true,
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* XML builder с подавлением пустых узлов.
|
|
23
|
+
* Используется для init.xml, SPXML output.
|
|
24
|
+
*/
|
|
25
|
+
exports.xmlBuilder = new fast_xml_parser_1.XMLBuilder({
|
|
26
|
+
...BASE_BUILDER_OPTIONS,
|
|
27
|
+
suppressEmptyNode: true,
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* XML builder без подавления пустых узлов.
|
|
31
|
+
* Используется для api_ext.xml, component SPXML.
|
|
32
|
+
*/
|
|
33
|
+
exports.xmlBuilderKeepEmpty = new fast_xml_parser_1.XMLBuilder({
|
|
34
|
+
...BASE_BUILDER_OPTIONS,
|
|
35
|
+
suppressEmptyNode: false,
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* XML parser с поддержкой атрибутов.
|
|
39
|
+
* Используется для чтения init.xml, api_ext.xml.
|
|
40
|
+
*/
|
|
41
|
+
exports.xmlParser = new fast_xml_parser_1.XMLParser({
|
|
42
|
+
ignoreAttributes: false,
|
|
43
|
+
attributeNamePrefix: '@_',
|
|
44
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UrlAppenPath = UrlAppenPath;
|
|
4
|
+
function UrlAppenPath(url, appendPath) {
|
|
5
|
+
var parsedUrl;
|
|
6
|
+
var addPath;
|
|
7
|
+
parsedUrl = BmParseUrl(url);
|
|
8
|
+
if (!parsedUrl.path.endsWith("/"))
|
|
9
|
+
parsedUrl.path += '/';
|
|
10
|
+
addPath = appendPath;
|
|
11
|
+
if (addPath.charAt(0) == '/')
|
|
12
|
+
addPath = addPath.slice(1);
|
|
13
|
+
parsedUrl.path += addPath;
|
|
14
|
+
return BmParsedUrl__GetStrValue(parsedUrl);
|
|
15
|
+
}
|
|
16
|
+
function BmParseUrl(urlStr) {
|
|
17
|
+
var obj = {};
|
|
18
|
+
var tempStr;
|
|
19
|
+
var pos;
|
|
20
|
+
tempStr = urlStr;
|
|
21
|
+
pos = String(tempStr).indexOf(':');
|
|
22
|
+
if (pos >= 0) {
|
|
23
|
+
obj.schema = tempStr.slice(0, pos);
|
|
24
|
+
tempStr = tempStr.slice(pos + 1);
|
|
25
|
+
}
|
|
26
|
+
if (tempStr.startsWith('//')) {
|
|
27
|
+
pos = String(tempStr).indexOf('/', 2);
|
|
28
|
+
if (pos < 0)
|
|
29
|
+
pos = tempStr.length;
|
|
30
|
+
obj.host = tempStr.slice(2, pos);
|
|
31
|
+
tempStr = tempStr.slice(pos);
|
|
32
|
+
}
|
|
33
|
+
if ((pos = String(tempStr).lastIndexOf('#')) > 0) {
|
|
34
|
+
obj.anchor = tempStr.slice(pos + 1);
|
|
35
|
+
tempStr = tempStr.slice(0, pos);
|
|
36
|
+
}
|
|
37
|
+
if ((pos = String(tempStr).lastIndexOf('?')) > 0) {
|
|
38
|
+
obj.param = tempStr.slice(pos + 1);
|
|
39
|
+
tempStr = tempStr.slice(0, pos);
|
|
40
|
+
}
|
|
41
|
+
obj.path = tempStr;
|
|
42
|
+
if (obj.path == "" && obj.host)
|
|
43
|
+
obj.path = "/";
|
|
44
|
+
return obj;
|
|
45
|
+
}
|
|
46
|
+
function BmParsedUrl__GetStrValue(url) {
|
|
47
|
+
var tempStr = "";
|
|
48
|
+
if (url.schema)
|
|
49
|
+
tempStr = url.schema + ":";
|
|
50
|
+
if (url.host || url.schema == "file")
|
|
51
|
+
tempStr += "//" + url.host;
|
|
52
|
+
tempStr += url.path;
|
|
53
|
+
if (url.param)
|
|
54
|
+
tempStr += "?" + url.param;
|
|
55
|
+
if (url.fragment)
|
|
56
|
+
tempStr += "#" + url.fragment;
|
|
57
|
+
return tempStr;
|
|
58
|
+
}
|
|
59
|
+
;
|
package/build/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
9
|
+
const commands_1 = require("./cli/commands");
|
|
10
|
+
commander_1.program
|
|
11
|
+
.name('btc')
|
|
12
|
+
.description(package_json_1.default.description)
|
|
13
|
+
.version(package_json_1.default.version);
|
|
14
|
+
// Команда init
|
|
15
|
+
commander_1.program
|
|
16
|
+
.command('init')
|
|
17
|
+
.description('Initialize a BorisType project and create a tsconfig.json file')
|
|
18
|
+
.action(async () => {
|
|
19
|
+
await (0, commands_1.initCommand)();
|
|
20
|
+
});
|
|
21
|
+
// Команда build (по умолчанию)
|
|
22
|
+
commander_1.program
|
|
23
|
+
.command('build [files...]', { isDefault: true })
|
|
24
|
+
.description('Transpile TypeScript to BorisScript')
|
|
25
|
+
.option('--outDir <dir>', 'Directory to save processed files')
|
|
26
|
+
.option('--include-non-ts-files', 'Process files that are not TypeScript', false)
|
|
27
|
+
.option('--retain-non-ascii-characters', 'Keep non-ASCII characters in source files', false)
|
|
28
|
+
.option('--remove-comments', 'Remove comments from source files', false)
|
|
29
|
+
.option('--off-babel', '[DEBUG] Toggle off all babel transformations', false)
|
|
30
|
+
.option('--compile-mode <mode>', 'Transpilation mode: bare | script | module (default: module)')
|
|
31
|
+
.option('--no-use-polyfill', '[deprecated] Use --compile-mode bare')
|
|
32
|
+
.option('--no-use-remodule', '[deprecated] Use --compile-mode bare')
|
|
33
|
+
.action(async (files, options) => {
|
|
34
|
+
await (0, commands_1.buildCommand)(files, options);
|
|
35
|
+
});
|
|
36
|
+
// Команда link
|
|
37
|
+
commander_1.program
|
|
38
|
+
.command('link')
|
|
39
|
+
.description('Link modules and dependencies into dist structure')
|
|
40
|
+
.option('--clean', 'Clean dist directory and cache before linking', false)
|
|
41
|
+
.option('--no-cache', 'Do not use cache for node_modules (but do not delete it)')
|
|
42
|
+
.option('--linking-system-as <mode>', 'How to link system packages: "standalone" or "component"', 'component')
|
|
43
|
+
.action(async (options) => {
|
|
44
|
+
const systemMode = options.linkingSystemAs;
|
|
45
|
+
// Commander парсит --no-cache как cache: false (по умолчанию cache: true)
|
|
46
|
+
await (0, commands_1.linkCommand)({ clean: options.clean, noCache: options.cache === false, linkingSystemAs: systemMode });
|
|
47
|
+
});
|
|
48
|
+
// Команда artifact
|
|
49
|
+
commander_1.program
|
|
50
|
+
.command('artifact')
|
|
51
|
+
.description('Create distribution archive from dist folder')
|
|
52
|
+
.option('--clean', 'Clean artifact directory before creating archives', false)
|
|
53
|
+
.action(async (options) => {
|
|
54
|
+
await (0, commands_1.artifactCommand)(options);
|
|
55
|
+
});
|
|
56
|
+
// Команда dev
|
|
57
|
+
commander_1.program
|
|
58
|
+
.command('dev')
|
|
59
|
+
.description('Start development mode with watch')
|
|
60
|
+
.option('--no-push', 'Disable auto-push to WSHCM server after linking')
|
|
61
|
+
.action(async (options) => {
|
|
62
|
+
await (0, commands_1.devCommand)({ push: options.push });
|
|
63
|
+
});
|
|
64
|
+
// Команда push (загрузка dist на WSHCM сервер)
|
|
65
|
+
commander_1.program
|
|
66
|
+
.command('push')
|
|
67
|
+
.description('Upload dist folder to WSHCM server')
|
|
68
|
+
.option('--host <host>', 'WSHCM server host (default: localhost)')
|
|
69
|
+
.option('--port <port>', 'WSHCM server port (default: 80)', parseInt)
|
|
70
|
+
.option('--username <username>', 'Username for authentication (default: user1)')
|
|
71
|
+
.option('--password <password>', 'Password for authentication (default: user1)')
|
|
72
|
+
.option('--https', 'Use HTTPS instead of HTTP', false)
|
|
73
|
+
.action(async (options) => {
|
|
74
|
+
await (0, commands_1.pushCommand)(options);
|
|
75
|
+
});
|
|
76
|
+
commander_1.program.parse(process.argv);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = replaceDestructuringPlugin;
|
|
4
|
+
const core_1 = require("@babel/core");
|
|
5
|
+
function makeDestructuringPolyfillExpression(functionName) {
|
|
6
|
+
return core_1.types.memberExpression(core_1.types.identifier('bt'), core_1.types.identifier(functionName));
|
|
7
|
+
}
|
|
8
|
+
function replaceDestructuringPlugin() {
|
|
9
|
+
return {
|
|
10
|
+
name: 'replace-destructuring',
|
|
11
|
+
visitor: {
|
|
12
|
+
VariableDeclaration(path, state) {
|
|
13
|
+
const declarations = path.node.declarations;
|
|
14
|
+
const newDeclarations = [];
|
|
15
|
+
// Process each variable declarator
|
|
16
|
+
declarations.forEach((declarator) => {
|
|
17
|
+
// Handle object destructuring
|
|
18
|
+
if (core_1.types.isObjectPattern(declarator.id)) {
|
|
19
|
+
const properties = declarator.id.properties;
|
|
20
|
+
const init = declarator.init;
|
|
21
|
+
const excludedKeys = [];
|
|
22
|
+
// Collect excluded keys and handle regular properties
|
|
23
|
+
properties.forEach((prop) => {
|
|
24
|
+
if (core_1.types.isObjectProperty(prop)) {
|
|
25
|
+
const key = prop.key;
|
|
26
|
+
const value = prop.value;
|
|
27
|
+
if (core_1.types.isIdentifier(key) && core_1.types.isIdentifier(value)) {
|
|
28
|
+
// Create new declaration: const key1 = testObject1.key1
|
|
29
|
+
const newDeclarator = core_1.types.variableDeclarator(core_1.types.identifier(value.name), core_1.types.memberExpression(init, key));
|
|
30
|
+
newDeclarations.push(core_1.types.variableDeclaration(path.node.kind, [newDeclarator]));
|
|
31
|
+
// Collect key for exclusion
|
|
32
|
+
excludedKeys.push(core_1.types.stringLiteral(key.name));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else if (core_1.types.isRestElement(prop)) {
|
|
36
|
+
state.needsObjectRest = true;
|
|
37
|
+
// Handle rest element (...restKeys)
|
|
38
|
+
const restIdent = prop.argument;
|
|
39
|
+
if (core_1.types.isIdentifier(restIdent)) {
|
|
40
|
+
const restCall = core_1.types.callExpression(makeDestructuringPolyfillExpression("object_rest"), [init, core_1.types.arrayExpression(excludedKeys)]);
|
|
41
|
+
const newDeclarator = core_1.types.variableDeclarator(restIdent, restCall);
|
|
42
|
+
newDeclarations.push(core_1.types.variableDeclaration(path.node.kind, [newDeclarator]));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
// Handle array destructuring
|
|
48
|
+
else if (core_1.types.isArrayPattern(declarator.id)) {
|
|
49
|
+
const elements = declarator.id.elements;
|
|
50
|
+
const init = declarator.init;
|
|
51
|
+
// Generate unique auxiliary variable name
|
|
52
|
+
const auxVarName = path.scope.generateUidIdentifier('arr');
|
|
53
|
+
// Create auxiliary variable: const _arr = ArrayDirect(testArray1)
|
|
54
|
+
const auxDeclarator = core_1.types.variableDeclarator(auxVarName, core_1.types.callExpression(core_1.types.identifier('ArrayDirect'), [init]));
|
|
55
|
+
newDeclarations.push(core_1.types.variableDeclaration(path.node.kind, [auxDeclarator]));
|
|
56
|
+
// Process array elements
|
|
57
|
+
elements.forEach((element, index) => {
|
|
58
|
+
if (core_1.types.isIdentifier(element)) {
|
|
59
|
+
// Create new declaration: const elem1 = _arr[0]
|
|
60
|
+
const newDeclarator = core_1.types.variableDeclarator(element, core_1.types.memberExpression(auxVarName, core_1.types.numericLiteral(index), true));
|
|
61
|
+
newDeclarations.push(core_1.types.variableDeclaration(path.node.kind, [newDeclarator]));
|
|
62
|
+
}
|
|
63
|
+
else if (core_1.types.isRestElement(element)) {
|
|
64
|
+
state.needsArrayRest = true;
|
|
65
|
+
// Handle rest element (...restElems)
|
|
66
|
+
const restIdent = element.argument;
|
|
67
|
+
if (core_1.types.isIdentifier(restIdent)) {
|
|
68
|
+
const restCall = core_1.types.callExpression(makeDestructuringPolyfillExpression("array_rest"), [auxVarName, core_1.types.numericLiteral(index)]);
|
|
69
|
+
const newDeclarator = core_1.types.variableDeclarator(restIdent, restCall);
|
|
70
|
+
newDeclarations.push(core_1.types.variableDeclaration(path.node.kind, [newDeclarator]));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
// Replace original declaration with new ones if any were created
|
|
77
|
+
if (newDeclarations.length > 0) {
|
|
78
|
+
path.replaceWithMultiple(newDeclarations);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = replaceForOfToForInPlugin;
|
|
4
|
+
const core_1 = require("@babel/core");
|
|
5
|
+
function replaceForOfToForInPlugin() {
|
|
6
|
+
return {
|
|
7
|
+
name: 'replace-for-of-to-for-in',
|
|
8
|
+
visitor: {
|
|
9
|
+
ForOfStatement(path) {
|
|
10
|
+
path.replaceWith(core_1.types.forInStatement(path.node.left, path.node.right, path.node.body));
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = collectLoopVariablesPlugin;
|
|
4
|
+
const core_1 = require("@babel/core");
|
|
5
|
+
const isLoop = (node) => {
|
|
6
|
+
return (core_1.types.isForStatement(node) ||
|
|
7
|
+
core_1.types.isForInStatement(node) ||
|
|
8
|
+
core_1.types.isForOfStatement(node) ||
|
|
9
|
+
core_1.types.isWhileStatement(node) ||
|
|
10
|
+
core_1.types.isDoWhileStatement(node));
|
|
11
|
+
};
|
|
12
|
+
// Initialize loop state for a top-level loop
|
|
13
|
+
function enterLoop(state) {
|
|
14
|
+
if (!state.isInLoop) {
|
|
15
|
+
state.isInLoop = true;
|
|
16
|
+
state.loopVariables = new Map();
|
|
17
|
+
state.loopCounter = (state.loopCounter || 0) + 1; // Increment loop counter
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
// Collect variables from ForIn/ForOf loop headers and replace declarations
|
|
21
|
+
function collectLoopHeaderVariables(path, state) {
|
|
22
|
+
if (core_1.types.isVariableDeclaration(path.node.left)) {
|
|
23
|
+
const kind = path.node.left.kind;
|
|
24
|
+
path.node.left.declarations.forEach((decl) => {
|
|
25
|
+
if (core_1.types.isIdentifier(decl.id)) {
|
|
26
|
+
const newName = `${decl.id.name}_loop${state.loopCounter}`;
|
|
27
|
+
state.loopVariables.set(decl.id.name, { kind, newName });
|
|
28
|
+
// Rename references in the scope
|
|
29
|
+
path.scope.rename(decl.id.name, newName);
|
|
30
|
+
}
|
|
31
|
+
else if (core_1.types.isObjectPattern(decl.id) || core_1.types.isArrayPattern(decl.id)) {
|
|
32
|
+
const identifiers = core_1.types.getBindingIdentifiers(decl.id);
|
|
33
|
+
Object.keys(identifiers).forEach((name) => {
|
|
34
|
+
const newName = `${name}_loop${state.loopCounter}`;
|
|
35
|
+
state.loopVariables.set(name, { kind, newName });
|
|
36
|
+
path.scope.rename(name, newName);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
// Replace VariableDeclaration with just the identifier or pattern
|
|
41
|
+
path.node.left = path.node.left.declarations[0].id;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Handle loop exit: log variables, insert declarations, reset state
|
|
45
|
+
function exitLoop(path, state) {
|
|
46
|
+
if (!path.findParent((p) => isLoop(p.node))) {
|
|
47
|
+
// Log collected variables
|
|
48
|
+
// console.log(
|
|
49
|
+
// 'Variables declared in loop:',
|
|
50
|
+
// Array.from(state.loopVariables.entries()).map(([name, { kind, newName }]) => [name, kind, newName])
|
|
51
|
+
// );
|
|
52
|
+
// Create variable declarations with empty initialization
|
|
53
|
+
const declarations = [];
|
|
54
|
+
state.loopVariables.forEach(({ kind, newName }) => {
|
|
55
|
+
const init = kind === 'const' ? core_1.types.nullLiteral() : core_1.types.identifier('undefined');
|
|
56
|
+
const declarator = core_1.types.variableDeclarator(core_1.types.identifier(newName), init);
|
|
57
|
+
declarations.push(core_1.types.variableDeclaration(kind, [declarator]));
|
|
58
|
+
});
|
|
59
|
+
// Insert declarations before the top-level loop
|
|
60
|
+
if (declarations.length > 0) {
|
|
61
|
+
const parent = path.getStatementParent();
|
|
62
|
+
if (parent) {
|
|
63
|
+
parent.insertBefore(declarations);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Reset state
|
|
67
|
+
state.isInLoop = false;
|
|
68
|
+
state.loopVariables = new Map();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function collectLoopVariablesPlugin() {
|
|
72
|
+
return {
|
|
73
|
+
name: 'collect-loop-variables',
|
|
74
|
+
pre() {
|
|
75
|
+
this.loopVariables = new Map();
|
|
76
|
+
this.isInLoop = false;
|
|
77
|
+
this.loopCounter = 0;
|
|
78
|
+
},
|
|
79
|
+
visitor: {
|
|
80
|
+
ForStatement: {
|
|
81
|
+
enter(path, state) {
|
|
82
|
+
enterLoop(state);
|
|
83
|
+
},
|
|
84
|
+
exit(path, state) {
|
|
85
|
+
exitLoop(path, state);
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
ForInStatement: {
|
|
89
|
+
enter(path, state) {
|
|
90
|
+
enterLoop(state);
|
|
91
|
+
collectLoopHeaderVariables(path, state);
|
|
92
|
+
},
|
|
93
|
+
exit(path, state) {
|
|
94
|
+
exitLoop(path, state);
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
ForOfStatement: {
|
|
98
|
+
enter(path, state) {
|
|
99
|
+
enterLoop(state);
|
|
100
|
+
collectLoopHeaderVariables(path, state);
|
|
101
|
+
},
|
|
102
|
+
exit(path, state) {
|
|
103
|
+
exitLoop(path, state);
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
WhileStatement: {
|
|
107
|
+
enter(path, state) {
|
|
108
|
+
enterLoop(state);
|
|
109
|
+
},
|
|
110
|
+
exit(path, state) {
|
|
111
|
+
exitLoop(path, state);
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
DoWhileStatement: {
|
|
115
|
+
enter(path, state) {
|
|
116
|
+
enterLoop(state);
|
|
117
|
+
},
|
|
118
|
+
exit(path, state) {
|
|
119
|
+
exitLoop(path, state);
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
VariableDeclaration(path, state) {
|
|
123
|
+
if (state.isInLoop) {
|
|
124
|
+
const kind = path.node.kind; // 'const', 'let', or 'var'
|
|
125
|
+
const assignments = [];
|
|
126
|
+
path.node.declarations.forEach((decl) => {
|
|
127
|
+
if (core_1.types.isIdentifier(decl.id)) {
|
|
128
|
+
const newName = `${decl.id.name}_loop${state.loopCounter}`;
|
|
129
|
+
state.loopVariables.set(decl.id.name, { kind, newName });
|
|
130
|
+
// Rename references in the scope
|
|
131
|
+
path.scope.rename(decl.id.name, newName);
|
|
132
|
+
// Create assignment expression (e.g., x_loopN = 5 or x_loopN = undefined)
|
|
133
|
+
const init = decl.init || core_1.types.identifier('undefined');
|
|
134
|
+
assignments.push(core_1.types.expressionStatement(core_1.types.assignmentExpression('=', core_1.types.identifier(newName), init)));
|
|
135
|
+
}
|
|
136
|
+
else if (core_1.types.isObjectPattern(decl.id) || core_1.types.isArrayPattern(decl.id)) {
|
|
137
|
+
// Handle destructuring
|
|
138
|
+
const identifiers = core_1.types.getBindingIdentifiers(decl.id);
|
|
139
|
+
Object.keys(identifiers).forEach((name) => {
|
|
140
|
+
const newName = `${name}_loop${state.loopCounter}`;
|
|
141
|
+
state.loopVariables.set(name, { kind, newName });
|
|
142
|
+
path.scope.rename(name, newName);
|
|
143
|
+
// Create individual assignments for each identifier
|
|
144
|
+
const init = decl.init || core_1.types.identifier('undefined');
|
|
145
|
+
assignments.push(core_1.types.expressionStatement(core_1.types.assignmentExpression('=', core_1.types.identifier(newName), init)));
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
// Replace VariableDeclaration with assignments
|
|
150
|
+
if (assignments.length > 0) {
|
|
151
|
+
path.replaceWithMultiple(assignments);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
path.remove(); // Remove empty declarations
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|