@kontur.candy/tools 2.254.0 → 2.256.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.
Files changed (76) hide show
  1. package/README.md +0 -16
  2. package/distr/Common/AsyncUtils.js +7 -0
  3. package/distr/Common/AsyncUtils.js.map +1 -1
  4. package/distr/Common/CommonConstants/DefaultServicesUrls.js +1 -3
  5. package/distr/Common/CommonConstants/DefaultServicesUrls.js.map +1 -1
  6. package/distr/Common/IntRangeUtils.js +4 -0
  7. package/distr/Common/IntRangeUtils.js.map +1 -1
  8. package/distr/Common/TypingUtils.js +4 -0
  9. package/distr/Common/TypingUtils.js.map +1 -1
  10. package/distr/Common/async/Channel.js +64 -0
  11. package/distr/Common/async/Channel.js.map +1 -0
  12. package/distr/Common/async/pool/AsyncPool.js +145 -0
  13. package/distr/Common/async/pool/AsyncPool.js.map +1 -0
  14. package/distr/Common/async/pool/FixedPool.js +29 -0
  15. package/distr/Common/async/pool/FixedPool.js.map +1 -0
  16. package/distr/Common/async/pool/LimitedPool.js +81 -0
  17. package/distr/Common/async/pool/LimitedPool.js.map +1 -0
  18. package/distr/Common/async/pool/Registry.js +73 -0
  19. package/distr/Common/async/pool/Registry.js.map +1 -0
  20. package/distr/Common/async/pool/index.js +13 -0
  21. package/distr/Common/async/pool/index.js.map +1 -0
  22. package/distr/Common/ds/LinkedList.js +64 -0
  23. package/distr/Common/ds/LinkedList.js.map +1 -0
  24. package/distr/Common/multithread/ThreadPool.js +74 -0
  25. package/distr/Common/multithread/ThreadPool.js.map +1 -0
  26. package/distr/Tools/src/BuildTasks/Form/GenerateForm.js +2 -1
  27. package/distr/Tools/src/BuildTasks/Form/GenerateForm.js.map +1 -1
  28. package/distr/Tools/src/BuildTasks/Form/NullFormGenerator.js +0 -3
  29. package/distr/Tools/src/BuildTasks/Form/NullFormGenerator.js.map +1 -1
  30. package/distr/Tools/src/BuildTasks/Generator/AcquirePublishedGeneratorTask.js +1 -1
  31. package/distr/Tools/src/BuildTasks/Generator/AcquirePublishedGeneratorTask.js.map +1 -1
  32. package/distr/Tools/src/BuildTasks/Generator/BuildGeneratorFromSourcesTask.js +13 -4
  33. package/distr/Tools/src/BuildTasks/Generator/BuildGeneratorFromSourcesTask.js.map +1 -1
  34. package/distr/Tools/src/BuildTasks/Generator/GeneratorWorker/CreateAsyncGenerator.js +29 -107
  35. package/distr/Tools/src/BuildTasks/Generator/GeneratorWorker/CreateAsyncGenerator.js.map +1 -1
  36. package/distr/Tools/src/BuildTasks/Generator/GeneratorWorker/GeneratorPool.js +57 -0
  37. package/distr/Tools/src/BuildTasks/Generator/GeneratorWorker/GeneratorPool.js.map +1 -0
  38. package/distr/Tools/src/BuildTasks/Generator/GeneratorWorker/GeneratorRequireUtils.js +29 -36
  39. package/distr/Tools/src/BuildTasks/Generator/GeneratorWorker/GeneratorRequireUtils.js.map +1 -1
  40. package/distr/Tools/src/BuildTasks/Generator/GeneratorWorker/ReadSourcesAndProcessSugarWorker.js +29 -36
  41. package/distr/Tools/src/BuildTasks/Generator/GeneratorWorker/ReadSourcesAndProcessSugarWorker.js.map +1 -1
  42. package/distr/Tools/src/BuildTasks/Generator/GeneratorWorker/TypedThreadWorker.js +14 -0
  43. package/distr/Tools/src/BuildTasks/Generator/GeneratorWorker/TypedThreadWorker.js.map +1 -0
  44. package/distr/Tools/src/BuildTasks/ResolveFormInfo.js +1 -1
  45. package/distr/Tools/src/BuildTasks/ResolveFormInfo.js.map +1 -1
  46. package/distr/Tools/src/CLICommands/BuildForms/BuildFormsOptions.js +0 -10
  47. package/distr/Tools/src/CLICommands/BuildForms/BuildFormsOptions.js.map +1 -1
  48. package/distr/Tools/src/CLICommands/BuildForms/RunBuildForms.js +2 -6
  49. package/distr/Tools/src/CLICommands/BuildForms/RunBuildForms.js.map +1 -1
  50. package/distr/Tools/src/CLICommands/BuildServer/BuildServerServerOptions.js +0 -22
  51. package/distr/Tools/src/CLICommands/BuildServer/BuildServerServerOptions.js.map +1 -1
  52. package/distr/Tools/src/CLICommands/BuildServer/ResourcesControllers/BuildServerBuildFormsController.js +1 -3
  53. package/distr/Tools/src/CLICommands/BuildServer/ResourcesControllers/BuildServerBuildFormsController.js.map +1 -1
  54. package/distr/Tools/src/CLICommands/BuildServer/ResourcesControllers/BuildServerFormInfoController.js +1 -1
  55. package/distr/Tools/src/CLICommands/BuildServer/ResourcesControllers/BuildServerFormInfoController.js.map +1 -1
  56. package/distr/Tools/src/CLICommands/BuildServer/ResourcesControllers/DevServers/BuildFormDevServer.js +2 -5
  57. package/distr/Tools/src/CLICommands/BuildServer/ResourcesControllers/DevServers/BuildFormDevServer.js.map +1 -1
  58. package/distr/Tools/src/CLICommands/DevBuild/DevBuildOptions.js +0 -10
  59. package/distr/Tools/src/CLICommands/DevBuild/DevBuildOptions.js.map +1 -1
  60. package/distr/Tools/src/CLICommands/DevBuild/RunDevBuild.js +1 -2
  61. package/distr/Tools/src/CLICommands/DevBuild/RunDevBuild.js.map +1 -1
  62. package/distr/Tools/src/CLICommands/Localization/RunLocalization.js +1 -1
  63. package/distr/Tools/src/CLICommands/Localization/RunLocalization.js.map +1 -1
  64. package/distr/Tools/src/CLICommands/SugarExtractor/Utils.js +1 -1
  65. package/distr/Tools/src/CLICommands/SugarExtractor/Utils.js.map +1 -1
  66. package/distr/Tools/src/LocalServerFrontEndDist/enhancedClient.js +1 -1
  67. package/distr/Tools/src/LocalServerFrontEndDist/index.js.map +1 -1
  68. package/distr/Tools/src/StaticFilesForProductionResourcesDir/client.js +13 -14
  69. package/distr/Tools/src/StaticFilesForProductionResourcesDir/client.js.map +1 -1
  70. package/distr/Tools/src/StaticFilesForProductionResourcesDir/client.min.js +13 -14
  71. package/distr/Tools/src/StaticFilesForProductionResourcesDir/client.min.js.map +1 -1
  72. package/package.json +1 -1
  73. package/distr/Tools/src/BuildTasks/Generator/GeneratorWorker/RequireUncached.js +0 -40
  74. package/distr/Tools/src/BuildTasks/Generator/GeneratorWorker/RequireUncached.js.map +0 -1
  75. package/distr/Tools/src/BuildTasks/Generator/GeneratorWorker/TypedProcessWorker.js +0 -19
  76. package/distr/Tools/src/BuildTasks/Generator/GeneratorWorker/TypedProcessWorker.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Registry.js","names":["State","exports","Registry","constructor","states","Map","stateOf","item","ensureHas","get","add","has","Error","set","Idle","capture","expect","Busy","free","doom","Doomed","remove","delete","findBusy","_this$states$entries$","entries","find","_","state","doomAll","idles","push"],"sources":["../../../../../Common/async/pool/Registry.ts"],"sourcesContent":["export const enum State {\n Idle = \"Idle\",\n Busy = \"Busy\",\n Doomed = \"Doomed\",\n}\n\nexport class Registry<Item> {\n private readonly states = new Map<Item, State>();\n\n public stateOf(item: Item): State {\n this.ensureHas(item);\n // @ts-expect-error item точно есть\n return this.states.get(item);\n }\n\n public add(item: Item): void {\n if (this.states.has(item)) {\n throw new Error(\"Registry: duplicate\");\n }\n this.states.set(item, State.Idle);\n }\n\n public capture(item: Item): Item {\n this.expect(item, State.Idle);\n this.states.set(item, State.Busy);\n return item;\n }\n\n public free(item: Item): void {\n this.expect(item, State.Busy);\n this.states.set(item, State.Idle);\n }\n\n public doom(item: Item): void {\n this.ensureHas(item);\n this.states.set(item, State.Doomed);\n }\n\n public remove(item: Item): void {\n if (!this.states.delete(item)) {\n throw new Error(\"Registry: remove unexpected\");\n }\n }\n\n public findBusy(): Item | undefined {\n return this.states.entries().find(([_, state]) => state === State.Busy)?.[0];\n }\n\n public doomAll(): Item[] {\n const idles: Item[] = [];\n for (const [item, state] of this.states.entries()) {\n this.states.set(item, State.Doomed);\n if (state === State.Idle) {\n idles.push(item);\n }\n }\n return idles;\n }\n\n private expect(item: Item, state: State): void {\n this.ensureHas(item);\n if (this.states.get(item) !== state) {\n throw new Error(\"Registry: unexpected state\");\n }\n }\n\n private ensureHas(item: Item): void {\n if (!this.states.has(item)) {\n throw new Error(\"Registry: unexpected item\");\n }\n }\n}\n"],"mappings":";;;;;;IAAkBA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";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "FixedPool", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _FixedPool.FixedPool;
10
+ }
11
+ });
12
+ var _FixedPool = require("./FixedPool");
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_FixedPool","require"],"sources":["../../../../../Common/async/pool/index.ts"],"sourcesContent":["export type { Disposable } from \"./AsyncPool\";\nexport { FixedPool } from \"./FixedPool\";\n"],"mappings":";;;;;;;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA","ignoreList":[]}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LinkedList = void 0;
7
+ class LinkedListClass {
8
+ constructor() {
9
+ this.length = 0;
10
+ this.first = null;
11
+ this.last = null;
12
+ }
13
+ empty() {
14
+ return this.length === 0;
15
+ }
16
+ notEmpty() {
17
+ return this.length > 0;
18
+ }
19
+ clear() {
20
+ this.length = 0;
21
+ this.first = null;
22
+ this.last = null;
23
+ }
24
+ forEach(fn) {
25
+ let current = this.first;
26
+ while (current !== null) {
27
+ fn(current.item);
28
+ current = current.next;
29
+ }
30
+ }
31
+ push(item) {
32
+ this.length++;
33
+ const last = this.last;
34
+ const element = {
35
+ prev: last,
36
+ next: null,
37
+ item: item
38
+ };
39
+ if (last) {
40
+ last.next = element;
41
+ } else {
42
+ this.first = element;
43
+ }
44
+ this.last = element;
45
+ }
46
+ shift() {
47
+ if (!this.first) {
48
+ return undefined;
49
+ }
50
+ this.length--;
51
+ const element = this.first;
52
+ if (this.last === element) {
53
+ this.first = null;
54
+ this.last = null;
55
+ } else {
56
+ this.first = element.next;
57
+ // @ts-expect-error last !== element => element.next !== null
58
+ this.first.prev = null;
59
+ }
60
+ return element.item;
61
+ }
62
+ }
63
+ const LinkedList = exports.LinkedList = LinkedListClass;
64
+ //# sourceMappingURL=LinkedList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkedList.js","names":["LinkedListClass","constructor","length","first","last","empty","notEmpty","clear","forEach","fn","current","item","next","push","element","prev","shift","undefined","LinkedList","exports"],"sources":["../../../../Common/ds/LinkedList.ts"],"sourcesContent":["interface Element<Item> {\n item: Item;\n prev: Element<Item> | null;\n next: Element<Item> | null;\n}\n\nclass LinkedListClass<Item> {\n private length = 0;\n private first: Element<Item> | null = null;\n private last: Element<Item> | null = null;\n\n public empty(): this is EmptyLinkedList<Item> {\n return this.length === 0;\n }\n\n public notEmpty(): this is NonEmptyLinkedList<Item> {\n return this.length > 0;\n }\n\n public clear(): void {\n this.length = 0;\n this.first = null;\n this.last = null;\n }\n\n public forEach(fn: (item: Item) => void): void {\n let current = this.first;\n while (current !== null) {\n fn(current.item);\n current = current.next;\n }\n }\n\n public push(item: Item): void {\n this.length++;\n const last = this.last;\n const element = { prev: last, next: null, item: item };\n if (last) {\n last.next = element;\n } else {\n this.first = element;\n }\n this.last = element;\n }\n\n public shift(this: NonEmptyLinkedList<Item>): Item;\n public shift(this: EmptyLinkedList<Item>): undefined;\n public shift(): Item | undefined;\n public shift(): Item | undefined {\n if (!this.first) {\n return undefined;\n }\n this.length--;\n const element = this.first;\n if (this.last === element) {\n this.first = null;\n this.last = null;\n } else {\n this.first = element.next;\n // @ts-expect-error last !== element => element.next !== null\n this.first.prev = null;\n }\n return element.item;\n }\n}\n\ndeclare const State: unique symbol;\ntype EmptyLinkedList<Item> = LinkedListClass<Item> & { readonly [State]: \"empty\" };\ntype NonEmptyLinkedList<Item> = LinkedListClass<Item> & { readonly [State]: \"nonempty\" };\n\nexport type LinkedList<Item> = EmptyLinkedList<Item> | NonEmptyLinkedList<Item>;\n\ninterface LinkedListCtor {\n new <Item>(): LinkedList<Item>;\n}\n\nexport const LinkedList = LinkedListClass as LinkedListCtor;\n"],"mappings":";;;;;;AAMA,MAAMA,eAAe,CAAO;EAAAC,YAA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,GAAG,IAAI;MACjB,IAAI,CAACC,IAAI,GAAG,IAAI;IACpB,CAAC,MAAM;MACH,IAAI,CAACD,KAAK,GAAGW,OAAO,CAACF,IAAI;MACzB;MACA,IAAI,CAACT,KAAK,CAACY,IAAI,GAAG,IAAI;IAC1B;IACA,OAAOD,OAAO,CAACH,IAAI;EACvB;AACJ;AAYO,MAAMO,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAGlB,eAAiC","ignoreList":[]}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ThreadPool = void 0;
7
+ var _nodeWorker_threads = require("node:worker_threads");
8
+ var _pool = require("../async/pool");
9
+ var _TypingUtils = require("../TypingUtils");
10
+ class ThreadPool {
11
+ constructor(ops) {
12
+ this.pool = void 0;
13
+ this.pool = new _pool.FixedPool({
14
+ size: ops.size,
15
+ fabric: this.fabric.bind(this, ops)
16
+ });
17
+ }
18
+
19
+ /**
20
+ * @throws при вызове после {@link ThreadPool.dispose}
21
+ */
22
+ exec(message) {
23
+ if (!this.pool) {
24
+ return Promise.reject(new Error("ThreadPool: exec on disposed pool"));
25
+ }
26
+ return this.pool.exec(({
27
+ worker
28
+ }) => this.call(worker, message));
29
+ }
30
+ async dispose() {
31
+ var _this$pool;
32
+ await ((_this$pool = this.pool) === null || _this$pool === void 0 ? void 0 : _this$pool.dispose());
33
+ // даем GC собрать
34
+ this.pool = undefined;
35
+ }
36
+ fabric(ops) {
37
+ const worker = new _nodeWorker_threads.Worker(ops.workerPath, ops.workerOptions);
38
+ return {
39
+ worker: worker,
40
+ dispose: () => worker.terminate().then(_TypingUtils.noop)
41
+ };
42
+ }
43
+ call(worker, message) {
44
+ const {
45
+ promise,
46
+ resolve,
47
+ reject
48
+ } = Promise.withResolvers();
49
+ const cleanup = () => {
50
+ worker.off("message", onMessage);
51
+ worker.off("error", onError);
52
+ worker.off("exit", onExit);
53
+ };
54
+ const onMessage = out => {
55
+ cleanup();
56
+ resolve(out);
57
+ };
58
+ const onError = err => {
59
+ cleanup();
60
+ reject(err);
61
+ };
62
+ const onExit = code => {
63
+ cleanup();
64
+ reject(new Error(`Worker exited with code ${code}`));
65
+ };
66
+ worker.once("message", onMessage);
67
+ worker.once("error", onError);
68
+ worker.once("exit", onExit);
69
+ worker.postMessage(message);
70
+ return promise;
71
+ }
72
+ }
73
+ exports.ThreadPool = ThreadPool;
74
+ //# sourceMappingURL=ThreadPool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThreadPool.js","names":["_nodeWorker_threads","require","_pool","_TypingUtils","ThreadPool","constructor","ops","pool","FixedPool","size","fabric","bind","exec","message","Promise","reject","Error","worker","call","dispose","_this$pool","undefined","Worker","workerPath","workerOptions","terminate","then","noop","promise","resolve","withResolvers","cleanup","off","onMessage","onError","onExit","out","err","code","once","postMessage","exports"],"sources":["../../../../Common/multithread/ThreadPool.ts"],"sourcesContent":["import { Worker, WorkerOptions } from \"node:worker_threads\";\n\nimport type { Disposable } from \"../async/pool\";\nimport { FixedPool } from \"../async/pool\";\nimport { noop } from \"../TypingUtils\";\n\ninterface Options {\n workerPath: string;\n workerOptions?: WorkerOptions;\n size: number;\n}\n\ninterface Thread extends Disposable {\n worker: Worker;\n}\n\nexport class ThreadPool {\n private pool?: FixedPool<Thread>;\n\n public constructor(ops: Options) {\n this.pool = new FixedPool({ size: ops.size, fabric: this.fabric.bind(this, ops) });\n }\n\n /**\n * @throws при вызове после {@link ThreadPool.dispose}\n */\n public exec<In, Out>(message: In): Promise<Out> {\n if (!this.pool) {\n return Promise.reject(new Error(\"ThreadPool: exec on disposed pool\"));\n }\n return this.pool.exec(({ worker }) => this.call<In, Out>(worker, message));\n }\n\n public async dispose(): Promise<void> {\n await this.pool?.dispose();\n // даем GC собрать\n this.pool = undefined;\n }\n\n private fabric(ops: Options): Thread {\n const worker = new Worker(ops.workerPath, ops.workerOptions);\n return { worker: worker, dispose: () => worker.terminate().then(noop) };\n }\n\n private call<In, Out>(worker: Worker, message: In): Promise<Out> {\n const { promise, resolve, reject } = Promise.withResolvers<Out>();\n const cleanup = (): void => {\n worker.off(\"message\", onMessage);\n worker.off(\"error\", onError);\n worker.off(\"exit\", onExit);\n };\n const onMessage = (out: Out): void => {\n cleanup();\n resolve(out);\n };\n const onError = (err: Error): void => {\n cleanup();\n reject(err);\n };\n const onExit = (code: number): void => {\n cleanup();\n reject(new Error(`Worker exited with code ${code}`));\n };\n worker.once(\"message\", onMessage);\n worker.once(\"error\", onError);\n worker.once(\"exit\", onExit);\n worker.postMessage(message);\n return promise;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AAGA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAYO,MAAMG,UAAU,CAAC;EAGbC,WAAWA,CAACC,GAAY,EAAE;IAAA,KAFzBC,IAAI;IAGR,IAAI,CAACA,IAAI,GAAG,IAAIC,eAAS,CAAC;MAAEC,IAAI,EAAEH,GAAG,CAACG,IAAI;MAAEC,MAAM,EAAE,IAAI,CAACA,MAAM,CAACC,IAAI,CAAC,IAAI,EAAEL,GAAG;IAAE,CAAC,CAAC;EACtF;;EAEA;AACJ;AACA;EACWM,IAAIA,CAAUC,OAAW,EAAgB;IAC5C,IAAI,CAAC,IAAI,CAACN,IAAI,EAAE;MACZ,OAAOO,OAAO,CAACC,MAAM,CAAC,IAAIC,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACzE;IACA,OAAO,IAAI,CAACT,IAAI,CAACK,IAAI,CAAC,CAAC;MAAEK;IAAO,CAAC,KAAK,IAAI,CAACC,IAAI,CAAUD,MAAM,EAAEJ,OAAO,CAAC,CAAC;EAC9E;EAEA,MAAaM,OAAOA,CAAA,EAAkB;IAAA,IAAAC,UAAA;IAClC,QAAAA,UAAA,GAAM,IAAI,CAACb,IAAI,cAAAa,UAAA,uBAATA,UAAA,CAAWD,OAAO,CAAC,CAAC;I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AAC;IAC3BlB,MAAM,CAACuB,WAAW,CAAC3B,OAAO,CAAC;IAC3B,OAAOe,OAAO;EAClB;AACJ;AAACa,OAAA,CAAArC,UAAA,GAAAA,UAAA","ignoreList":[]}
@@ -24,7 +24,8 @@ class DefaultFileWriter {
24
24
  }
25
25
  }
26
26
  async function generateForm(formSourcesPath, farmDirectory, generator, parentLogger = (0, _StaticLogger.getLogger)(), generationOptions, fileWriter = new DefaultFileWriter()) {
27
- const logger = parentLogger.withPrefix(`GENERATE:${(0, _FormPathUtils.extractGfvFromFormPath)(formSourcesPath)}`);
27
+ const gfv = (0, _FormPathUtils.extractGfvFromFormPath)(formSourcesPath);
28
+ const logger = parentLogger.withPrefix(`GENERATE:${gfv}`);
28
29
  const action = (0, _ILogger.buildActionBegin)(logger, "Generation");
29
30
  const generatedContent = await generator.readSourcesAndProcessSugar(formSourcesPath, farmDirectory, generationOptions);
30
31
  logger.log("Writing files");
@@ -1 +1 @@
1
- {"version":3,"file":"GenerateForm.js","names":["path","_interopRequireWildcard","require","_fsExtra","_FsUtils","_ILogger","_StaticLogger","_FormPathUtils","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DefaultFileWriter","writeBatch","fileBatch","filePath","keys","content","undefined","ensureDir","parse","dir","writeFileAsync","generateForm","formSourcesPath","farmDirectory","generator","parentLogger","getLogger","generationOptions","fileWriter","logger","withPrefix","extractGfvFromFormPath","action","buildActionBegin","generatedContent","readSourcesAndProcessSugar","log","writeGeneratedFiles","join","complete","candyFormContent","outputDirectory"],"sources":["../../../../../src/BuildTasks/Form/GenerateForm.ts"],"sourcesContent":["import * as path from \"path\";\n\nimport { ensureDir } from \"fs-extra\";\n\nimport { writeFileAsync } from \"../../Commons/FsUtils\";\nimport { buildActionBegin, ILogger } from \"../../Commons/Logging/ILogger\";\nimport { getLogger } from \"../../Commons/Logging/StaticLogger\";\nimport { FormResources, FormSource, SugarContent } from \"../FormSource\";\nimport { extractGfvFromFormPath } from \"../../../../Common/FormPathUtils\";\nimport { ExtractorResult } from \"../../../../Common/TextExtractor/TextExtractorTypes\";\n\nexport interface GeneratedForm {\n [relativeFileName: string]: Buffer | string;\n}\n\nexport interface LocalizationDictionaryContent {\n [relativeFileName: string]: string;\n}\n\nexport interface LocalizationEntryPoint {\n getLocalizedSugar(sugarFiles: SugarContent, resources: FormResources): Promise<SugarContent>;\n getDictionary(sugarFiles: SugarContent, resources: FormResources): Promise<LocalizationDictionaryContent>;\n}\n\nexport interface FormGenerator {\n readSources(formSourcesPath: string, farmDirectory: string): Promise<FormSource>;\n getAllDependencies(formSourcesPath: string, farmDirectory: string): Promise<string[]>;\n getAllDependenciesHash(formSourcesPath: string, farmDirectory: string): Promise<string>;\n supportsDependenciesExtraction(): Promise<boolean>;\n readSourcesAndProcessSugar(\n formSourcesPath: string,\n farmDirectory: string,\n generationOptions?: GenerationOptions\n ): Promise<GeneratedForm>;\n getLocalizedSugar(sugarFiles: SugarContent, resources: FormResources): Promise<SugarContent>;\n getDictionary(sugarFiles: SugarContent, resources: FormResources): Promise<LocalizationDictionaryContent>;\n getSugarTexts(formSourcesPath: string, farmDirectory: string): Promise<ExtractorResult>;\n}\n\nexport interface GenerationOptions {\n skipCodeReformatting: boolean;\n resourcesHash: string;\n}\n\nexport interface IFileWriter {\n writeBatch(fileBatch: { [absoluteFileName: string]: string }): Promise<void>;\n}\n\nclass DefaultFileWriter implements IFileWriter {\n public async writeBatch(fileBatch: { [absoluteFileName: string]: string }): Promise<void> {\n for (const filePath of Object.keys(fileBatch)) {\n const content = fileBatch[filePath];\n if (content != undefined && content !== \"\") {\n await ensureDir(path.parse(filePath).dir);\n await writeFileAsync(filePath, content);\n }\n }\n }\n}\n\nexport async function generateForm(\n formSourcesPath: string,\n farmDirectory: string,\n generator: FormGenerator,\n parentLogger: ILogger = getLogger(),\n generationOptions?: GenerationOptions,\n fileWriter: IFileWriter = new DefaultFileWriter()\n): Promise<void> {\n const logger = parentLogger.withPrefix(`GENERATE:${extractGfvFromFormPath(formSourcesPath)}`);\n const action = buildActionBegin(logger, \"Generation\");\n const generatedContent = await generator.readSourcesAndProcessSugar(\n formSourcesPath,\n farmDirectory,\n generationOptions\n );\n logger.log(\"Writing files\");\n await writeGeneratedFiles(generatedContent, path.join(formSourcesPath, \"form\"), fileWriter);\n action.complete();\n}\n\nasync function writeGeneratedFiles(\n candyFormContent: GeneratedForm,\n outputDirectory: string,\n fileWriter: IFileWriter\n): Promise<void> {\n const fileBatch = {};\n for (const filePath of Object.keys(candyFormContent)) {\n const content = candyFormContent[filePath];\n if (content != undefined && content !== \"\") {\n // @ts-ignore\n fileBatch[path.join(outputDirectory, filePath)] = content;\n }\n }\n await fileWriter.writeBatch(fileBatch);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAEA,IAAAK,cAAA,GAAAL,OAAA;AAA0E,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAA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ACK,UAAU,CAAC,YAAY,IAAAC,qCAAsB,EAACT,eAAe,CAAC,EAAE,CAAC;EAC7F,MAAMU,MAAM,GAAG,IAAAC,yBAAgB,EAACJ,MAAM,EAAE,YAAY,CAAC;EACrD,MAAMK,gBAAgB,GAAG,MAAMV,SAAS,CAACW,0BAA0B,CAC/Db,eAAe,EACfC,aAAa,EACbI,iBACJ,CAAC;EACDE,MAAM,CAACO,GAAG,CAAC,eAAe,CAAC;EAC3B,MAAMC,mBAAmB,CAACH,gBAAgB,EAAEpD,IAAI,CAACwD,IAAI,CAAChB,eAAe,EAAE,MAAM,CAAC,EAAEM,UAAU,CAAC;EAC3FI,MAAM,CAACO,QAAQ,CAAC,CAAC;AACrB;AAEA,eAAeF,mBAAmBA,CAC9BG,gBAA+B,EAC/BC,eAAuB,EACvBb,UAAuB,EACV;EACb,MAAMhB,SAAS,GAAG,CAAC,CAAC;EACpB,KAAK,MAAMC,QAAQ,IAAIX,MAAM,CAACY,IAAI,CAAC0B,gBAAgB,CAAC,EAAE;IAClD,MAAMzB,OAAO,GAAGyB,gBAAgB,CAAC3B,QAAQ,CAAC;IAC1C,IAAIE,OAAO,IAAIC,SAAS,IAAID,OAAO,KAAK,EAAE,EAAE;MACxC;MACAH,SAAS,CAAC9B,IAAI,CAACwD,IAAI,CAACG,eAAe,EAAE5B,QAAQ,CAAC,CAAC,GAAGE,OAAO;IAC7D;EACJ;EACA,MAAMa,UAAU,CAACjB,UAAU,CAACC,SAAS,CAAC;AAC1C","ignoreList":[]}
1
+ {"version":3,"file":"GenerateForm.js","names":["path","_interopRequireWildcard","require","_fsExtra","_FsUtils","_ILogger","_StaticLogger","_FormPathUtils","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DefaultFileWriter","writeBatch","fileBatch","filePath","keys","content","undefined","ensureDir","parse","dir","writeFileAsync","generateForm","formSourcesPath","farmDirectory","generator","parentLogger","getLogger","generationOptions","fileWriter","gfv","extractGfvFromFormPath","logger","withPrefix","action","buildActionBegin","generatedContent","readSourcesAndProcessSugar","log","writeGeneratedFiles","join","complete","candyFormContent","outputDirectory"],"sources":["../../../../../src/BuildTasks/Form/GenerateForm.ts"],"sourcesContent":["import * as path from \"path\";\n\nimport { ensureDir } from \"fs-extra\";\n\nimport { writeFileAsync } from \"../../Commons/FsUtils\";\nimport { buildActionBegin, ILogger } from \"../../Commons/Logging/ILogger\";\nimport { getLogger } from \"../../Commons/Logging/StaticLogger\";\nimport { FormResources, FormSource, SugarContent } from \"../FormSource\";\nimport { extractGfvFromFormPath } from \"../../../../Common/FormPathUtils\";\nimport { ExtractorResult } from \"../../../../Common/TextExtractor/TextExtractorTypes\";\n\nexport interface GeneratedForm {\n [relativeFileName: string]: Buffer | string;\n}\n\nexport interface LocalizationDictionaryContent {\n [relativeFileName: string]: string;\n}\n\nexport interface FormGenerator {\n readSources(formSourcesPath: string, farmDirectory: string): Promise<FormSource>;\n getAllDependencies(formSourcesPath: string, farmDirectory: string): Promise<string[]>;\n getAllDependenciesHash(formSourcesPath: string, farmDirectory: string): Promise<string>;\n readSourcesAndProcessSugar(\n formSourcesPath: string,\n farmDirectory: string,\n generationOptions?: GenerationOptions\n ): Promise<GeneratedForm>;\n getLocalizedSugar(sugarFiles: SugarContent, resources: FormResources): Promise<SugarContent>;\n getDictionary(sugarFiles: SugarContent, resources: FormResources): Promise<LocalizationDictionaryContent>;\n getSugarTexts(formSourcesPath: string, farmDirectory: string): Promise<ExtractorResult>;\n dispose?(): Promise<void>;\n}\n\nexport interface GenerationOptions {\n resourcesHash: string;\n}\n\nexport interface IFileWriter {\n writeBatch(fileBatch: { [absoluteFileName: string]: string }): Promise<void>;\n}\n\nclass DefaultFileWriter implements IFileWriter {\n public async writeBatch(fileBatch: { [absoluteFileName: string]: string }): Promise<void> {\n for (const filePath of Object.keys(fileBatch)) {\n const content = fileBatch[filePath];\n if (content != undefined && content !== \"\") {\n await ensureDir(path.parse(filePath).dir);\n await writeFileAsync(filePath, content);\n }\n }\n }\n}\n\nexport async function generateForm(\n formSourcesPath: string,\n farmDirectory: string,\n generator: FormGenerator,\n parentLogger: ILogger = getLogger(),\n generationOptions?: GenerationOptions,\n fileWriter: IFileWriter = new DefaultFileWriter()\n): Promise<void> {\n const gfv = extractGfvFromFormPath(formSourcesPath);\n const logger = parentLogger.withPrefix(`GENERATE:${gfv}`);\n const action = buildActionBegin(logger, \"Generation\");\n const generatedContent = await generator.readSourcesAndProcessSugar(\n formSourcesPath,\n farmDirectory,\n generationOptions\n );\n logger.log(\"Writing files\");\n await writeGeneratedFiles(generatedContent, path.join(formSourcesPath, \"form\"), fileWriter);\n action.complete();\n}\n\nasync function writeGeneratedFiles(\n candyFormContent: GeneratedForm,\n outputDirectory: string,\n fileWriter: IFileWriter\n): Promise<void> {\n const fileBatch = {};\n for (const filePath of Object.keys(candyFormContent)) {\n const content = candyFormContent[filePath];\n if (content != undefined && content !== \"\") {\n // @ts-ignore\n fileBatch[path.join(outputDirectory, filePath)] = content;\n }\n }\n await fileWriter.writeBatch(fileBatch);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAEA,IAAAK,cAAA,GAAAL,OAAA;AAA0E,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAA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w new Error("GenerationNotSupported");
25
25
  }
26
- supportsDependenciesExtraction() {
27
- throw new Error("GenerationNotSupported");
28
- }
29
26
  getSugarTexts() {
30
27
  throw new Error("GenerationNotSupported");
31
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"NullFormGenerator.js","names":["NullFormGenerator","getAllDependencies","Error","getAllDependenciesHash","getDictionary","getLocalizedSugar","readSources","readSourcesAndProcessSugar","supportsDependenciesExtraction","getSugarTexts","exports"],"sources":["../../../../../src/BuildTasks/Form/NullFormGenerator.ts"],"sourcesContent":["import { FormSource, SugarContent } from \"../FormSource\";\nimport { ExtractorResult } from \"../../../../Common/TextExtractor/TextExtractorTypes\";\n\nimport { FormGenerator, GeneratedForm, LocalizationDictionaryContent } from \"./GenerateForm\";\n\nexport class NullFormGenerator implements FormGenerator {\n public getAllDependencies(): Promise<string[]> {\n throw new Error(\"GenerationNotSupported\");\n }\n\n public getAllDependenciesHash(): Promise<string> {\n throw new Error(\"GenerationNotSupported\");\n }\n\n public getDictionary(): Promise<LocalizationDictionaryContent> {\n throw new Error(\"GenerationNotSupported\");\n }\n\n public getLocalizedSugar(): Promise<SugarContent> {\n throw new Error(\"GenerationNotSupported\");\n }\n\n public readSources(): Promise<FormSource> {\n throw new Error(\"GenerationNotSupported\");\n }\n\n public readSourcesAndProcessSugar(): Promise<GeneratedForm> {\n throw new Error(\"GenerationNotSupported\");\n }\n\n public supportsDependenciesExtraction(): Promise<boolean> {\n throw new Error(\"GenerationNotSupported\");\n }\n\n public getSugarTexts(): Promise<ExtractorResult> {\n throw new Error(\"GenerationNotSupported\");\n }\n}\n"],"mappings":";;;;;;AAKO,MAAMA,iBAAiB,CAA0B;EAC7CC,kBAAkBA,CAAA,EAAsB;IAC3C,MAAM,IAAIC,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEOC,sBAAsBA,CAAA,EAAoB;IAC7C,MAAM,IAAID,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEOE,aAAaA,CAAA,EAA2C;IAC3D,MAAM,IAAIF,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEOG,iBAAiBA,CAAA,EAA0B;IAC9C,MAAM,IAAIH,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEOI,WAAWA,CAAA,EAAwB;IACtC,MAAM,IAAIJ,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEOK,0BAA0BA,CAAA,EAA2B;IACxD,MAAM,IAAIL,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEOM,8BAA8BA,CAAA,EAAqB;IACtD,MAAM,IAAIN,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEOO,aAAaA,CAAA,EAA6B;IAC7C,MAAM,IAAIP,KAAK,CAAC,wBAAwB,CAAC;EAC7C;AACJ;AAACQ,OAAA,CAAAV,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"file":"NullFormGenerator.js","names":["NullFormGenerator","getAllDependencies","Error","getAllDependenciesHash","getDictionary","getLocalizedSugar","readSources","readSourcesAndProcessSugar","getSugarTexts","exports"],"sources":["../../../../../src/BuildTasks/Form/NullFormGenerator.ts"],"sourcesContent":["import { FormSource, SugarContent } from \"../FormSource\";\nimport { ExtractorResult } from \"../../../../Common/TextExtractor/TextExtractorTypes\";\n\nimport { FormGenerator, GeneratedForm, LocalizationDictionaryContent } from \"./GenerateForm\";\n\nexport class NullFormGenerator implements FormGenerator {\n public getAllDependencies(): Promise<string[]> {\n throw new Error(\"GenerationNotSupported\");\n }\n\n public getAllDependenciesHash(): Promise<string> {\n throw new Error(\"GenerationNotSupported\");\n }\n\n public getDictionary(): Promise<LocalizationDictionaryContent> {\n throw new Error(\"GenerationNotSupported\");\n }\n\n public getLocalizedSugar(): Promise<SugarContent> {\n throw new Error(\"GenerationNotSupported\");\n }\n\n public readSources(): Promise<FormSource> {\n throw new Error(\"GenerationNotSupported\");\n }\n\n public readSourcesAndProcessSugar(): Promise<GeneratedForm> {\n throw new Error(\"GenerationNotSupported\");\n }\n\n public getSugarTexts(): Promise<ExtractorResult> {\n throw new Error(\"GenerationNotSupported\");\n }\n}\n"],"mappings":";;;;;;AAKO,MAAMA,iBAAiB,CAA0B;EAC7CC,kBAAkBA,CAAA,EAAsB;IAC3C,MAAM,IAAIC,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEOC,sBAAsBA,CAAA,EAAoB;IAC7C,MAAM,IAAID,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEOE,aAAaA,CAAA,EAA2C;IAC3D,MAAM,IAAIF,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEOG,iBAAiBA,CAAA,EAA0B;IAC9C,MAAM,IAAIH,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEOI,WAAWA,CAAA,EAAwB;IACtC,MAAM,IAAIJ,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEOK,0BAA0BA,CAAA,EAA2B;IACxD,MAAM,IAAIL,KAAK,CAAC,wBAAwB,CAAC;EAC7C;EAEOM,aAAaA,CAAA,EAA6B;IAC7C,MAAM,IAAIN,KAAK,CAAC,wBAAwB,CAAC;EAC7C;AACJ;AAACO,OAAA,CAAAT,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -40,7 +40,7 @@ class AcquirePublishedGeneratorTask extends _ChainableValueProducer.ObservableVa
40
40
  this.logger.log(`Acquiring generator ${this.version}`);
41
41
  await this.execute(generatorDirectory, `npm install @kontur.candy/generator@${this.version}`);
42
42
  }
43
- const result = (0, _CreateAsyncGenerator.createAsyncGenerator)(path.join(generatorDirectory, "node_modules", "@kontur.candy", "generator"), false, false);
43
+ const result = (0, _CreateAsyncGenerator.createAsyncGenerator)(path.join(generatorDirectory, "node_modules", "@kontur.candy", "generator"));
44
44
  this.acquiredGenerator = result;
45
45
  }
46
46
  });
@@ -1 +1 @@
1
- {"version":3,"file":"AcquirePublishedGeneratorTask.js","names":["_child_process","require","path","_interopRequireWildcard","_fsExtra","_pLimit","_interopRequireDefault","_StaticLogger","_ChainableValueProducer","_TypingUtils","_CreateAsyncGenerator","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","AcquirePublishedGeneratorTask","ObservableValueProducerBase","constructor","version","candyModulesDirectory","useVersionFromCache","logger","getLogger","cacheDirectory","acquiredGenerator","acquireLimit","pLimit","withPrefix","getCurrentValue","undefined","generatorDirectory","join","useGeneratorFromCache","pathExists","prepareGeneratorDirectory","log","execute","result","createAsyncGenerator","Error","beginListening","stopListening","ensureDir","outputFile","resolve","command","workingDirectory","executable","executableArguments","split","Promise","rejectPromise","npm_config_registry","_","env","process","watchProcess","spawn","reject","cwd","shell","windowsHide","stdio","stdout","on","data","verbose","toString","stderr","code","exports"],"sources":["../../../../../src/BuildTasks/Generator/AcquirePublishedGeneratorTask.ts"],"sourcesContent":["import { spawn } from \"child_process\";\nimport * as path from \"path\";\n\nimport { ensureDir, outputFile, pathExists } from \"fs-extra\";\nimport pLimit from \"p-limit\";\n\nimport { ILogger } from \"../../Commons/Logging/ILogger\";\nimport { getLogger } from \"../../Commons/Logging/StaticLogger\";\nimport { ObservableValueProducerBase } from \"../../Commons/TasksCore/ChainableValueProducer\";\nimport { FormGenerator } from \"../Form/GenerateForm\";\nimport { reject } from \"../../../../Common/TypingUtils\";\n\nimport { createAsyncGenerator } from \"./GeneratorWorker/CreateAsyncGenerator\";\n\nexport class AcquirePublishedGeneratorTask extends ObservableValueProducerBase<FormGenerator> {\n private readonly logger: ILogger;\n private readonly version: string;\n private readonly cacheDirectory: string;\n private acquiredGenerator?: FormGenerator;\n private readonly useVersionFromCache: boolean;\n private readonly acquireLimit = pLimit(1);\n\n public constructor(\n version: string,\n candyModulesDirectory: string,\n useVersionFromCache: boolean,\n logger: ILogger = getLogger()\n ) {\n super();\n this.logger = logger.withPrefix(\"GENERATOR\");\n this.version = version;\n this.cacheDirectory = candyModulesDirectory;\n this.useVersionFromCache = useVersionFromCache;\n }\n\n public async getCurrentValue(): Promise<FormGenerator> {\n if (this.acquiredGenerator == undefined) {\n await this.acquireLimit(async () => {\n if (this.acquiredGenerator == undefined) {\n const generatorDirectory = path.join(this.cacheDirectory, \"generators\", this.version);\n const useGeneratorFromCache = this.useVersionFromCache && (await pathExists(generatorDirectory));\n\n if (!useGeneratorFromCache) {\n await this.prepareGeneratorDirectory(generatorDirectory);\n this.logger.log(`Acquiring generator ${this.version}`);\n await this.execute(generatorDirectory, `npm install @kontur.candy/generator@${this.version}`);\n }\n\n const result = createAsyncGenerator(\n path.join(generatorDirectory, \"node_modules\", \"@kontur.candy\", \"generator\"),\n false,\n false\n );\n this.acquiredGenerator = result;\n }\n });\n }\n if (this.acquiredGenerator == undefined) {\n throw new Error(\"InvalidProgramState\");\n }\n return this.acquiredGenerator;\n }\n\n protected async beginListening(): Promise<void> {\n // Нет предков и тут нечего наблюдать\n }\n\n protected async stopListening(): Promise<void> {\n // Нет предков и тут нечего наблюдать\n }\n\n private async prepareGeneratorDirectory(generatorDirectory: string): Promise<void> {\n await ensureDir(generatorDirectory);\n await outputFile(\n path.resolve(generatorDirectory, \"package.json\"),\n `{ \"name\": \"generator\", \"version\": \"1.0.0\", \"description\": \"Generator\", \"author\": \"\" }`\n );\n }\n\n private execute(generatorDirectory: string, command: string): Promise<void> {\n const workingDirectory = generatorDirectory;\n const [executable, ...executableArguments] = command.split(\" \");\n return new Promise<void>((resolve, rejectPromise) => {\n const { npm_config_registry: _, ...env } = process.env;\n const watchProcess = spawn(executable ?? reject(), executableArguments, {\n cwd: workingDirectory,\n shell: true,\n windowsHide: true,\n stdio: \"pipe\",\n env: env,\n });\n watchProcess.stdout.on(\"data\", (data: Buffer | string) => {\n this.logger.verbose(data.toString());\n });\n watchProcess.stderr.on(\"data\", (data: Buffer | string) => {\n this.logger.verbose(data.toString());\n });\n watchProcess.on(\"exit\", code => {\n if (code !== 0) {\n rejectPromise(new Error(`Command ${command} exited with code ${code}`));\n } else {\n resolve();\n }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AAAW,mBAAM,EAAC,CAAC,EAAEV,mBAAmB,EAAE;QACpEW,GAAG,EAAEb,gBAAgB;QACrBc,KAAK,EAAE,IAAI;QACXC,WAAW,EAAE,IAAI;QACjBC,KAAK,EAAE,MAAM;QACbR,GAAG,EAAEA;MACT,CAAC,CAAC;MACFE,YAAY,CAACO,MAAM,CAACC,EAAE,CAAC,MAAM,EAAGC,IAAqB,IAAK;QACtD,IAAI,CAAC5C,MAAM,CAAC6C,OAAO,CAACD,IAAI,CAACE,QAAQ,CAAC,CAAC,CAAC;MACxC,CAAC,CAAC;MACFX,YAAY,CAACY,MAAM,CAACJ,EAAE,CAAC,MAAM,EAAGC,IAAqB,IAAK;QACtD,IAAI,CAAC5C,MAAM,CAAC6C,OAAO,CAACD,IAAI,CAACE,QAAQ,CAAC,CAAC,CAAC;MACxC,CAAC,CAAC;MACFX,YAAY,CAACQ,EAAE,CAAC,MAAM,EAAEK,IAAI,IAAI;QAC5B,IAAIA,IAAI,KAAK,CAAC,EAAE;UACZlB,aAAa,CAAC,IAAIZ,KAAK,CAAC,WAAWM,OAAO,qBAAqBwB,IAAI,EAAE,CAAC,CAAC;QAC3E,CAAC,MAAM;UACHzB,OAAO,CAAC,CAAC;QACb;MACJ,CAAC,CAAC;IACN,CAAC,CAAC;EACN;AACJ;AAAC0B,OAAA,CAAAvD,6BAAA,GAAAA,6BAAA","ignoreList":[]}
1
+ {"version":3,"file":"AcquirePublishedGeneratorTask.js","names":["_child_process","require","path","_interopRequireWildcard","_fsExtra","_pLimit","_interopRequireDefault","_StaticLogger","_ChainableValueProducer","_TypingUtils","_CreateAsyncGenerator","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","AcquirePublishedGeneratorTask","ObservableValueProducerBase","constructor","version","candyModulesDirectory","useVersionFromCache","logger","getLogger","cacheDirectory","acquiredGenerator","acquireLimit","pLimit","withPrefix","getCurrentValue","undefined","generatorDirectory","join","useGeneratorFromCache","pathExists","prepareGeneratorDirectory","log","execute","result","createAsyncGenerator","Error","beginListening","stopListening","ensureDir","outputFile","resolve","command","workingDirectory","executable","executableArguments","split","Promise","rejectPromise","npm_config_registry","_","env","process","watchProcess","spawn","reject","cwd","shell","windowsHide","stdio","stdout","on","data","verbose","toString","stderr","code","exports"],"sources":["../../../../../src/BuildTasks/Generator/AcquirePublishedGeneratorTask.ts"],"sourcesContent":["import { spawn } from \"child_process\";\nimport * as path from \"path\";\n\nimport { ensureDir, outputFile, pathExists } from \"fs-extra\";\nimport pLimit from \"p-limit\";\n\nimport { ILogger } from \"../../Commons/Logging/ILogger\";\nimport { getLogger } from \"../../Commons/Logging/StaticLogger\";\nimport { ObservableValueProducerBase } from \"../../Commons/TasksCore/ChainableValueProducer\";\nimport { FormGenerator } from \"../Form/GenerateForm\";\nimport { reject } from \"../../../../Common/TypingUtils\";\n\nimport { createAsyncGenerator } from \"./GeneratorWorker/CreateAsyncGenerator\";\n\nexport class AcquirePublishedGeneratorTask extends ObservableValueProducerBase<FormGenerator> {\n private readonly logger: ILogger;\n private readonly version: string;\n private readonly cacheDirectory: string;\n private acquiredGenerator?: FormGenerator;\n private readonly useVersionFromCache: boolean;\n private readonly acquireLimit = pLimit(1);\n\n public constructor(\n version: string,\n candyModulesDirectory: string,\n useVersionFromCache: boolean,\n logger: ILogger = getLogger()\n ) {\n super();\n this.logger = logger.withPrefix(\"GENERATOR\");\n this.version = version;\n this.cacheDirectory = candyModulesDirectory;\n this.useVersionFromCache = useVersionFromCache;\n }\n\n public async getCurrentValue(): Promise<FormGenerator> {\n if (this.acquiredGenerator == undefined) {\n await this.acquireLimit(async () => {\n if (this.acquiredGenerator == undefined) {\n const generatorDirectory = path.join(this.cacheDirectory, \"generators\", this.version);\n const useGeneratorFromCache = this.useVersionFromCache && (await pathExists(generatorDirectory));\n\n if (!useGeneratorFromCache) {\n await this.prepareGeneratorDirectory(generatorDirectory);\n this.logger.log(`Acquiring generator ${this.version}`);\n await this.execute(generatorDirectory, `npm install @kontur.candy/generator@${this.version}`);\n }\n\n const result = createAsyncGenerator(\n path.join(generatorDirectory, \"node_modules\", \"@kontur.candy\", \"generator\")\n );\n this.acquiredGenerator = result;\n }\n });\n }\n if (this.acquiredGenerator == undefined) {\n throw new Error(\"InvalidProgramState\");\n }\n return this.acquiredGenerator;\n }\n\n protected async beginListening(): Promise<void> {\n // Нет предков и тут нечего наблюдать\n }\n\n protected async stopListening(): Promise<void> {\n // Нет предков и тут нечего наблюдать\n }\n\n private async prepareGeneratorDirectory(generatorDirectory: string): Promise<void> {\n await ensureDir(generatorDirectory);\n await outputFile(\n path.resolve(generatorDirectory, \"package.json\"),\n `{ \"name\": \"generator\", \"version\": \"1.0.0\", \"description\": \"Generator\", \"author\": \"\" }`\n );\n }\n\n private execute(generatorDirectory: string, command: string): Promise<void> {\n const workingDirectory = generatorDirectory;\n const [executable, ...executableArguments] = command.split(\" \");\n return new Promise<void>((resolve, rejectPromise) => {\n const { npm_config_registry: _, ...env } = process.env;\n const watchProcess = spawn(executable ?? reject(), executableArguments, {\n cwd: workingDirectory,\n shell: true,\n windowsHide: true,\n stdio: \"pipe\",\n env: env,\n });\n watchProcess.stdout.on(\"data\", (data: Buffer | string) => {\n this.logger.verbose(data.toString());\n });\n watchProcess.stderr.on(\"data\", (data: Buffer | string) => {\n this.logger.verbose(data.toString());\n });\n watchProcess.on(\"exit\", code => {\n if (code !== 0) {\n rejectPromise(new Error(`Command ${command} exited with code ${code}`));\n } else {\n resolve();\n }\n });\n });\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAC,uBAAA,CAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAC,sBAAA,CAAAL,OAAA;AAGA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,uBAAA,GAAAP,OAAA;AAEA,IAAAQ,Y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O,CAACD,IAAI,CAACE,QAAQ,CAAC,CAAC,CAAC;MACxC,CAAC,CAAC;MACFX,YAAY,CAACY,MAAM,CAACJ,EAAE,CAAC,MAAM,EAAGC,IAAqB,IAAK;QACtD,IAAI,CAAC5C,MAAM,CAAC6C,OAAO,CAACD,IAAI,CAACE,QAAQ,CAAC,CAAC,CAAC;MACxC,CAAC,CAAC;MACFX,YAAY,CAACQ,EAAE,CAAC,MAAM,EAAEK,IAAI,IAAI;QAC5B,IAAIA,IAAI,KAAK,CAAC,EAAE;UACZlB,aAAa,CAAC,IAAIZ,KAAK,CAAC,WAAWM,OAAO,qBAAqBwB,IAAI,EAAE,CAAC,CAAC;QAC3E,CAAC,MAAM;UACHzB,OAAO,CAAC,CAAC;QACb;MACJ,CAAC,CAAC;IACN,CAAC,CAAC;EACN;AACJ;AAAC0B,OAAA,CAAAvD,6BAAA,GAAAA,6BAAA","ignoreList":[]}
@@ -26,8 +26,11 @@ class BuildGeneratorFromSourcesTask extends _ChainableValueProducer.ObservableVa
26
26
  this.buildProcess = void 0;
27
27
  this.buildResultWatcher = void 0;
28
28
  this.handleUpdate = async () => {
29
+ var _this$currentGenerato, _this$currentGenerato2;
29
30
  this.logger.log("Generator sources updated");
30
- await this.emitUpdate((0, _CreateAsyncGenerator.createAsyncGenerator)(_path.default.join(this.pathToEngineSources, "Generator"), this.useWatch, this.useWatch));
31
+ await ((_this$currentGenerato = this.currentGenerator) === null || _this$currentGenerato === void 0 || (_this$currentGenerato2 = _this$currentGenerato.dispose) === null || _this$currentGenerato2 === void 0 ? void 0 : _this$currentGenerato2.call(_this$currentGenerato));
32
+ this.currentGenerator = (0, _CreateAsyncGenerator.createAsyncGenerator)(_path.default.join(this.pathToEngineSources, "Generator"));
33
+ await this.emitUpdate(this.currentGenerator);
31
34
  };
32
35
  this.logger = logger.withPrefix("GENERATOR");
33
36
  this.pathToEngineSources = pathToEngineSources;
@@ -41,7 +44,7 @@ class BuildGeneratorFromSourcesTask extends _ChainableValueProducer.ObservableVa
41
44
  if (this.buildProcess == undefined) {
42
45
  this.buildProcess = await this.runWatchProcessStarted();
43
46
  this.buildResultWatcher = await this.createBuildResultWatcher(_path.default.join(this.pathToEngineSources, "Generator", "dist"));
44
- this.currentGenerator = (0, _CreateAsyncGenerator.createAsyncGenerator)(_path.default.join(this.pathToEngineSources, "Generator"), this.useWatch, this.useWatch);
47
+ this.currentGenerator = (0, _CreateAsyncGenerator.createAsyncGenerator)(_path.default.join(this.pathToEngineSources, "Generator"));
45
48
  }
46
49
  } else {
47
50
  this.currentGenerator = await this.acquireGeneratorFromSources();
@@ -56,6 +59,7 @@ class BuildGeneratorFromSourcesTask extends _ChainableValueProducer.ObservableVa
56
59
  this.useWatch = true;
57
60
  }
58
61
  async stopListening() {
62
+ var _this$currentGenerato3, _this$currentGenerato4;
59
63
  if (this.buildProcess != undefined) {
60
64
  try {
61
65
  const buildProcess = this.buildProcess;
@@ -68,6 +72,7 @@ class BuildGeneratorFromSourcesTask extends _ChainableValueProducer.ObservableVa
68
72
  if (this.buildResultWatcher != undefined) {
69
73
  this.buildResultWatcher.close();
70
74
  }
75
+ await ((_this$currentGenerato3 = this.currentGenerator) === null || _this$currentGenerato3 === void 0 || (_this$currentGenerato4 = _this$currentGenerato3.dispose) === null || _this$currentGenerato4 === void 0 ? void 0 : _this$currentGenerato4.call(_this$currentGenerato3));
71
76
  this.useWatch = false;
72
77
  }
73
78
  async acquireGeneratorFromSources() {
@@ -76,7 +81,7 @@ class BuildGeneratorFromSourcesTask extends _ChainableValueProducer.ObservableVa
76
81
  await (0, _ExecUtils.execCommandAsync)(this.logger, `npm run generator:build`, {
77
82
  cwd: buildDirectory
78
83
  });
79
- const result = (0, _CreateAsyncGenerator.createAsyncGenerator)(_path.default.join(this.pathToEngineSources, "Generator"), this.useWatch, this.useWatch);
84
+ const result = (0, _CreateAsyncGenerator.createAsyncGenerator)(_path.default.join(this.pathToEngineSources, "Generator"));
80
85
  action.complete();
81
86
  return result;
82
87
  }
@@ -107,7 +112,11 @@ class BuildGeneratorFromSourcesTask extends _ChainableValueProducer.ObservableVa
107
112
  ignoreInitial: true,
108
113
  cwd: pathToGeneratorOutputDir,
109
114
  ignorePermissionErrors: false,
110
- usePolling: true
115
+ usePolling: true,
116
+ awaitWriteFinish: {
117
+ stabilityThreshold: 200,
118
+ pollInterval: 50
119
+ }
111
120
  });
112
121
  const handleAnyFsEventDebounced = _lodash.default.debounce(() => this.handleUpdate(), 500);
113
122
  watcher.on("all", handleAnyFsEventDebounced);
@@ -1 +1 @@
1
- {"version":3,"file":"BuildGeneratorFromSourcesTask.js","names":["_path","_interopRequireDefault","require","_chokidar","_lodash","_pLimit","_ExecUtils","_ILogger","_StaticLogger","_ChainableValueProducer","_ProcessUtils","_CreateAsyncGenerator","generatorBuildLimit","pLimit","BuildGeneratorFromSourcesTask","ObservableValueProducerBase","constructor","pathToEngineSources","logger","getLogger","useWatch","currentGenerator","buildProcess","buildResultWatcher","handleUpdate","log","emitUpdate","createAsyncGenerator","path","join","withPrefix","getCurrentValue","undefined","runWatchProcessStarted","createBuildResultWatcher","acquireGeneratorFromSources","Error","beginListening","stopListening","kill","error","close","action","buildActionBegin","buildDirectory","getBuildDirectory","execCommandAsync","cwd","result","complete","ProcessUtils","createShellProcess","onStdOut","subscribe","data","verbose","toString","onStdErr","start","waitFirstCompilationCompleted","waitOutputIncludesString","pathToGeneratorOutputDir","maskToObserveGeneratorChanges","watcher","watch","ignoreInitial","ignorePermissionErrors","usePolling","handleAnyFsEventDebounced","_","debounce","on","exports"],"sources":["../../../../../src/BuildTasks/Generator/BuildGeneratorFromSourcesTask.ts"],"sourcesContent":["import { FSWatcher } from \"fs\";\nimport path from \"path\";\n\nimport { watch } from \"chokidar\";\nimport _ from \"lodash\";\nimport pLimit from \"p-limit\";\n\nimport { execCommandAsync } from \"../../Commons/ExecUtils\";\nimport { buildActionBegin, ILogger } from \"../../Commons/Logging/ILogger\";\nimport { getLogger } from \"../../Commons/Logging/StaticLogger\";\nimport { ObservableValueProducerBase } from \"../../Commons/TasksCore/ChainableValueProducer\";\nimport { FormGenerator } from \"../Form/GenerateForm\";\nimport { ProcessUtils } from \"../ProcessUtils/ProcessUtils\";\nimport { ShellProcessHandle } from \"../ProcessUtils/ShellProcessHandle\";\n\nimport { createAsyncGenerator } from \"./GeneratorWorker/CreateAsyncGenerator\";\n\nconst generatorBuildLimit = pLimit(1);\n\nexport class BuildGeneratorFromSourcesTask extends ObservableValueProducerBase<FormGenerator> {\n private readonly pathToEngineSources: string;\n private readonly logger: ILogger;\n private useWatch = false;\n private currentGenerator?: FormGenerator;\n private buildProcess?: ShellProcessHandle;\n private buildResultWatcher?: FSWatcher;\n\n public constructor(pathToEngineSources: string, logger: ILogger = getLogger()) {\n super();\n this.logger = logger.withPrefix(\"GENERATOR\");\n this.pathToEngineSources = pathToEngineSources;\n }\n\n public async getCurrentValue(): Promise<FormGenerator> {\n return generatorBuildLimit(async () => {\n if (this.currentGenerator != undefined) {\n return this.currentGenerator;\n }\n if (this.useWatch) {\n if (this.buildProcess == undefined) {\n this.buildProcess = await this.runWatchProcessStarted();\n this.buildResultWatcher = await this.createBuildResultWatcher(\n path.join(this.pathToEngineSources, \"Generator\", \"dist\")\n );\n this.currentGenerator = createAsyncGenerator(\n path.join(this.pathToEngineSources, \"Generator\"),\n this.useWatch,\n this.useWatch\n );\n }\n } else {\n this.currentGenerator = await this.acquireGeneratorFromSources();\n }\n if (this.currentGenerator == undefined) {\n throw new Error(\"InvalidProgramState\");\n }\n return this.currentGenerator;\n });\n }\n\n protected async beginListening(): Promise<void> {\n this.useWatch = true;\n }\n\n protected async stopListening(): Promise<void> {\n if (this.buildProcess != undefined) {\n try {\n const buildProcess = this.buildProcess;\n this.buildProcess = undefined;\n await buildProcess.kill();\n } catch (error) {\n this.logger.error(`Failed to stop process: ${error}`);\n }\n }\n if (this.buildResultWatcher != undefined) {\n this.buildResultWatcher.close();\n }\n this.useWatch = false;\n }\n\n private readonly handleUpdate = async (): Promise<void> => {\n this.logger.log(\"Generator sources updated\");\n await this.emitUpdate(\n createAsyncGenerator(path.join(this.pathToEngineSources, \"Generator\"), this.useWatch, this.useWatch)\n );\n };\n\n private async acquireGeneratorFromSources(): Promise<FormGenerator> {\n const action = buildActionBegin(this.logger, \"Build generator\");\n const buildDirectory = await this.getBuildDirectory();\n await execCommandAsync(this.logger, `npm run generator:build`, {\n cwd: buildDirectory,\n });\n const result = createAsyncGenerator(\n path.join(this.pathToEngineSources, \"Generator\"),\n this.useWatch,\n this.useWatch\n );\n action.complete();\n return result;\n }\n\n private async getBuildDirectory(): Promise<string> {\n return this.pathToEngineSources;\n }\n\n private async runWatchProcessStarted(): Promise<ShellProcessHandle> {\n this.logger.log(\"Start watch\");\n const buildDirectory = await this.getBuildDirectory();\n const result = ProcessUtils.createShellProcess(\n \"npm\",\n [\"run\", \"generator:build\", \"--\", \"--watch\"],\n buildDirectory\n );\n result.onStdOut.subscribe(data => {\n this.logger.verbose(data.toString());\n });\n result.onStdErr.subscribe(data => {\n this.logger.verbose(data.toString());\n });\n result.start();\n await this.waitFirstCompilationCompleted(result);\n this.logger.log(\"Successfully complied\");\n return result;\n }\n\n private async waitFirstCompilationCompleted(result: ShellProcessHandle): Promise<void> {\n await result.waitOutputIncludesString(\"Successfully compiled\");\n }\n\n private async createBuildResultWatcher(pathToGeneratorOutputDir: string): Promise<FSWatcher> {\n const maskToObserveGeneratorChanges = [\"Generator/src/**/*.js\", \"index.js\"];\n const watcher = watch(maskToObserveGeneratorChanges, {\n ignoreInitial: true,\n cwd: pathToGeneratorOutputDir,\n ignorePermissionErrors: false,\n usePolling: true,\n });\n const handleAnyFsEventDebounced = _.debounce(() => this.handleUpdate(), 500);\n watcher.on(\"all\", handleAnyFsEventDebounced);\n watcher.on(\"error\", handleAnyFsEventDebounced);\n // @ts-ignore\n return watcher;\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,SAAA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,QAAQ,CAAC,CAAC,CAAC;IACxC,CAAC,CAAC;IACFR,MAAM,CAACU,KAAK,CAAC,CAAC;IACd,MAAM,IAAI,CAACC,6BAA6B,CAACX,MAAM,CAAC;IAChD,IAAI,CAAC9B,MAAM,CAACO,GAAG,CAAC,uBAAuB,CAAC;IACxC,OAAOuB,MAAM;EACjB;EAEA,MAAcW,6BAA6BA,CAACX,MAA0B,EAAiB;IACnF,MAAMA,MAAM,CAACY,wBAAwB,CAAC,uBAAuB,CAAC;EAClE;EAEA,MAAc1B,wBAAwBA,CAAC2B,wBAAgC,EAAsB;IACzF,MAAMC,6BAA6B,GAAG,CAAC,uBAAuB,EAAE,UAAU,CAAC;IAC3E,MAAMC,OAAO,GAAG,IAAAC,eAAK,EAACF,6BAA6B,EAAE;MACjDG,aAAa,EAAE,IAAI;MACnBlB,GAAG,EAAEc,wBAAwB;MAC7BK,sBAAsB,EAAE,KAAK;MAC7BC,UAAU,EAAE;IAChB,CAAC,CAAC;IACF,MAAMC,yBAAyB,GAAGC,eAAC,CAACC,QAAQ,CAAC,MAAM,IAAI,CAAC9C,YAAY,CAAC,CAAC,EAAE,GAAG,CAAC;IAC5EuC,OAAO,CAACQ,EAAE,CAAC,KAAK,EAAEH,yBAAyB,CAAC;IAC5CL,OAAO,CAACQ,EAAE,CAAC,OAAO,EAAEH,yBAAyB,CAAC;IAC9C;IACA,OAAOL,OAAO;EAClB;AACJ;AAACS,OAAA,CAAA1D,6BAAA,GAAAA,6BAAA","ignoreList":[]}
1
+ {"version":3,"file":"BuildGeneratorFromSourcesTask.js","names":["_path","_interopRequireDefault","require","_chokidar","_lodash","_pLimit","_ExecUtils","_ILogger","_StaticLogger","_ChainableValueProducer","_ProcessUtils","_CreateAsyncGenerator","generatorBuildLimit","pLimit","BuildGeneratorFromSourcesTask","ObservableValueProducerBase","constructor","pathToEngineSources","logger","getLogger","useWatch","currentGenerator","buildProcess","buildResultWatcher","handleUpdate","_this$currentGenerato","_this$currentGenerato2","log","dispose","call","createAsyncGenerator","path","join","emitUpdate","withPrefix","getCurrentValue","undefined","runWatchProcessStarted","createBuildResultWatcher","acquireGeneratorFromSources","Error","beginListening","stopListening","_this$currentGenerato3","_this$currentGenerato4","kill","error","close","action","buildActionBegin","buildDirectory","getBuildDirectory","execCommandAsync","cwd","result","complete","ProcessUtils","createShellProcess","onStdOut","subscribe","data","verbose","toString","onStdErr","start","waitFirstCompilationCompleted","waitOutputIncludesString","pathToGeneratorOutputDir","maskToObserveGeneratorChanges","watcher","watch","ignoreInitial","ignorePermissionErrors","usePolling","awaitWriteFinish","stabilityThreshold","pollInterval","handleAnyFsEventDebounced","_","debounce","on","exports"],"sources":["../../../../../src/BuildTasks/Generator/BuildGeneratorFromSourcesTask.ts"],"sourcesContent":["import { FSWatcher } from \"fs\";\nimport path from \"path\";\n\nimport { watch } from \"chokidar\";\nimport _ from \"lodash\";\nimport pLimit from \"p-limit\";\n\nimport { execCommandAsync } from \"../../Commons/ExecUtils\";\nimport { buildActionBegin, ILogger } from \"../../Commons/Logging/ILogger\";\nimport { getLogger } from \"../../Commons/Logging/StaticLogger\";\nimport { ObservableValueProducerBase } from \"../../Commons/TasksCore/ChainableValueProducer\";\nimport { FormGenerator } from \"../Form/GenerateForm\";\nimport { ProcessUtils } from \"../ProcessUtils/ProcessUtils\";\nimport { ShellProcessHandle } from \"../ProcessUtils/ShellProcessHandle\";\n\nimport { createAsyncGenerator } from \"./GeneratorWorker/CreateAsyncGenerator\";\n\nconst generatorBuildLimit = pLimit(1);\n\nexport class BuildGeneratorFromSourcesTask extends ObservableValueProducerBase<FormGenerator> {\n private readonly pathToEngineSources: string;\n private readonly logger: ILogger;\n private useWatch = false;\n private currentGenerator?: FormGenerator;\n private buildProcess?: ShellProcessHandle;\n private buildResultWatcher?: FSWatcher;\n\n public constructor(pathToEngineSources: string, logger: ILogger = getLogger()) {\n super();\n this.logger = logger.withPrefix(\"GENERATOR\");\n this.pathToEngineSources = pathToEngineSources;\n }\n\n public async getCurrentValue(): Promise<FormGenerator> {\n return generatorBuildLimit(async () => {\n if (this.currentGenerator != undefined) {\n return this.currentGenerator;\n }\n if (this.useWatch) {\n if (this.buildProcess == undefined) {\n this.buildProcess = await this.runWatchProcessStarted();\n this.buildResultWatcher = await this.createBuildResultWatcher(\n path.join(this.pathToEngineSources, \"Generator\", \"dist\")\n );\n this.currentGenerator = createAsyncGenerator(path.join(this.pathToEngineSources, \"Generator\"));\n }\n } else {\n this.currentGenerator = await this.acquireGeneratorFromSources();\n }\n if (this.currentGenerator == undefined) {\n throw new Error(\"InvalidProgramState\");\n }\n return this.currentGenerator;\n });\n }\n\n protected async beginListening(): Promise<void> {\n this.useWatch = true;\n }\n\n protected async stopListening(): Promise<void> {\n if (this.buildProcess != undefined) {\n try {\n const buildProcess = this.buildProcess;\n this.buildProcess = undefined;\n await buildProcess.kill();\n } catch (error) {\n this.logger.error(`Failed to stop process: ${error}`);\n }\n }\n if (this.buildResultWatcher != undefined) {\n this.buildResultWatcher.close();\n }\n await this.currentGenerator?.dispose?.();\n this.useWatch = false;\n }\n\n private readonly handleUpdate = async (): Promise<void> => {\n this.logger.log(\"Generator sources updated\");\n await this.currentGenerator?.dispose?.();\n this.currentGenerator = createAsyncGenerator(path.join(this.pathToEngineSources, \"Generator\"));\n await this.emitUpdate(this.currentGenerator);\n };\n\n private async acquireGeneratorFromSources(): Promise<FormGenerator> {\n const action = buildActionBegin(this.logger, \"Build generator\");\n const buildDirectory = await this.getBuildDirectory();\n await execCommandAsync(this.logger, `npm run generator:build`, {\n cwd: buildDirectory,\n });\n const result = createAsyncGenerator(path.join(this.pathToEngineSources, \"Generator\"));\n action.complete();\n return result;\n }\n\n private async getBuildDirectory(): Promise<string> {\n return this.pathToEngineSources;\n }\n\n private async runWatchProcessStarted(): Promise<ShellProcessHandle> {\n this.logger.log(\"Start watch\");\n const buildDirectory = await this.getBuildDirectory();\n const result = ProcessUtils.createShellProcess(\n \"npm\",\n [\"run\", \"generator:build\", \"--\", \"--watch\"],\n buildDirectory\n );\n result.onStdOut.subscribe(data => {\n this.logger.verbose(data.toString());\n });\n result.onStdErr.subscribe(data => {\n this.logger.verbose(data.toString());\n });\n result.start();\n await this.waitFirstCompilationCompleted(result);\n this.logger.log(\"Successfully complied\");\n return result;\n }\n\n private async waitFirstCompilationCompleted(result: ShellProcessHandle): Promise<void> {\n await result.waitOutputIncludesString(\"Successfully compiled\");\n }\n\n private async createBuildResultWatcher(pathToGeneratorOutputDir: string): Promise<FSWatcher> {\n const maskToObserveGeneratorChanges = [\"Generator/src/**/*.js\", \"index.js\"];\n const watcher = watch(maskToObserveGeneratorChanges, {\n ignoreInitial: true,\n cwd: pathToGeneratorOutputDir,\n ignorePermissionErrors: false,\n usePolling: true,\n awaitWriteFinish: { stabilityThreshold: 200, pollInterval: 50 },\n });\n const handleAnyFsEventDebounced = _.debounce(() => this.handleUpdate(), 500);\n watcher.on(\"all\", handleAnyFsEventDebounced);\n watcher.on(\"error\", handleAnyFsEventDebounced);\n // @ts-ignore\n return watcher;\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,uBAAA,GAAAP,OAAA;AAEA,IAAAQ,aAAA,GAAAR,OAAA;AAGA,IAAAS,qBAAA,GAAAT,OAAA;AAEA,MAAMU,mBAAmB,GAAG,IAAAC,eAAM,EAAC,CAAC,CAAC;AAE9B,MAAMC,6BAA6B,SAASC,mDAA2B,CAAgB;EAQnFC,WAAWA,CAACC,mBAA2B,EAAEC,MAAe,GAAG,IAAAC,uBAAS,EAAC,CAAC,EAAE;IAC3E,KAAK,CAAC,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GAAG,CAAC,uBAAuB,CAAC;IACxC,OAAO2B,MAAM;EACjB;EAEA,MAAcW,6BAA6BA,CAACX,MAA0B,EAAiB;IACnF,MAAMA,MAAM,CAACY,wBAAwB,CAAC,uBAAuB,CAAC;EAClE;EAEA,MAAc5B,wBAAwBA,CAAC6B,wBAAgC,EAAsB;IACzF,MAAMC,6BAA6B,GAAG,CAAC,uBAAuB,EAAE,UAAU,CAAC;IAC3E,MAAMC,OAAO,GAAG,IAAAC,eAAK,EAACF,6BAA6B,EAAE;MACjDG,aAAa,EAAE,IAAI;MACnBlB,GAAG,EAAEc,wBAAwB;MAC7BK,sBAAsB,EAAE,KAAK;MAC7BC,UAAU,EAAE,IAAI;MAChBC,gBAAgB,EAAE;QAAEC,kBAAkB,EAAE,GAAG;QAAEC,YAAY,EAAE;MAAG;IAClE,CAAC,CAAC;IACF,MAAMC,yBAAyB,GAAGC,eAAC,CAACC,QAAQ,CAAC,MAAM,IAAI,CAACvD,YAAY,CAAC,CAAC,EAAE,GAAG,CAAC;IAC5E6C,OAAO,CAACW,EAAE,CAAC,KAAK,EAAEH,yBAAyB,CAAC;IAC5CR,OAAO,CAACW,EAAE,CAAC,OAAO,EAAEH,yBAAyB,CAAC;IAC9C;IACA,OAAOR,OAAO;EAClB;AACJ;AAACY,OAAA,CAAAnE,6BAAA,GAAAA,6BAAA","ignoreList":[]}
@@ -3,119 +3,41 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createAsyncGenerator = createAsyncGenerator;
7
- var _child_process = require("child_process");
8
- var _IterableUtils = require("../../../../../Common/IterableUtils");
6
+ exports.createAsyncGenerator = void 0;
9
7
  var _GeneratorRequireUtils = require("./GeneratorRequireUtils");
10
- /* eslint-disable no-console */
11
-
8
+ var _GeneratorPool = require("./GeneratorPool");
12
9
  class GeneratorAsyncProxy {
13
- constructor(pathToGeneratorRootDir, purgeCache, useGeneratorRestarting) {
14
- this.pathToGeneratorRootDir = void 0;
15
- this.generatorSourcesImporter = void 0;
16
- this.purgeCache = void 0;
17
- this.useGeneratorRestarting = void 0;
18
- this.generatorProcess = void 0;
19
- this.maxRequestNumber = 0;
20
- this.processSugarDeferredMap = new Map();
21
- this.useGeneratorRestarting = useGeneratorRestarting;
22
- this.pathToGeneratorRootDir = pathToGeneratorRootDir;
23
- this.purgeCache = purgeCache;
24
- this.generatorSourcesImporter = new _GeneratorRequireUtils.GeneratorSourcesImporter(this.pathToGeneratorRootDir, this.purgeCache);
25
- }
26
- async getLocalizedSugar(sugarFiles, resources) {
27
- const localizationEntryPoint = await this.generatorSourcesImporter.importLocalization();
28
- if (localizationEntryPoint == undefined) {
29
- throw new Error("Данная версия генератора не поддерживает локализацию.");
30
- }
31
- return localizationEntryPoint.getLocalizedSugar(sugarFiles, resources);
32
- }
33
- async getDictionary(sugarFiles, resources) {
34
- const localizationEntryPoint = await this.generatorSourcesImporter.importLocalization();
35
- if (localizationEntryPoint == undefined) {
36
- throw new Error("Данная версия генератора не поддерживает локализацию.");
37
- }
38
- return localizationEntryPoint.getDictionary(sugarFiles, resources);
39
- }
40
- async readSources(formSourcesPath, farmDirectory) {
41
- const readSources = await this.generatorSourcesImporter.importReadSources();
42
- return await readSources(formSourcesPath, farmDirectory);
43
- }
44
- async getSugarTexts(formSourcesPath, farmDirectory) {
45
- const getSugarTexts = await this.generatorSourcesImporter.importGetSugarTexts();
46
- return await getSugarTexts(formSourcesPath, farmDirectory);
47
- }
48
- async getAllDependencies(formSourcesPath, farmDirectory) {
49
- const getAllDependencies = await this.generatorSourcesImporter.importGetAllDependencies();
50
- return await getAllDependencies(formSourcesPath, farmDirectory);
51
- }
52
- async supportsDependenciesExtraction() {
53
- const getAllDependenciesHash = await this.generatorSourcesImporter.importGetAllDependenciesHash();
54
- return getAllDependenciesHash != undefined;
55
- }
56
- async getAllDependenciesHash(formSourcesPath, farmDirectory) {
57
- const getAllDependenciesHash = await this.generatorSourcesImporter.importGetAllDependenciesHash();
58
- return await getAllDependenciesHash(formSourcesPath, farmDirectory);
10
+ constructor(generatorPath) {
11
+ this.generatorPath = void 0;
12
+ this.pool = void 0;
13
+ this.readSources = void 0;
14
+ this.getSugarTexts = void 0;
15
+ this.getAllDependencies = void 0;
16
+ this.getAllDependenciesHash = void 0;
17
+ this.getDictionary = void 0;
18
+ this.getLocalizedSugar = void 0;
19
+ this.generatorPath = generatorPath;
20
+ const generator = (0, _GeneratorRequireUtils.importGenerator)(generatorPath);
21
+ this.readSources = generator.readSources;
22
+ this.getSugarTexts = generator.getSugarTexts;
23
+ this.getAllDependencies = generator.getAllDependencies;
24
+ this.getAllDependenciesHash = generator.getAllDependenciesHash;
25
+ this.getDictionary = generator.getDictionary;
26
+ this.getLocalizedSugar = generator.getLocalizedSugar;
59
27
  }
60
28
  async readSourcesAndProcessSugar(formSourcesPath, farmDirectory, generationOptions) {
61
- this.maxRequestNumber++;
62
- const currentRequestNumber = this.maxRequestNumber;
63
- const promise = new Promise((resolve, reject) => {
64
- this.processSugarDeferredMap.set(currentRequestNumber, {
65
- resolve: resolve,
66
- reject: reject
67
- });
68
- });
69
- if (!this.generatorProcess) {
70
- this.generatorProcess = this.forkReadSourcesAndProcessSugarWorker();
71
- }
72
- if (this.useGeneratorRestarting) {
73
- if (this.maxRequestNumber % 10 === 0) {
74
- console.log("Restarting generator");
75
- this.generatorProcess.kill();
76
- this.generatorProcess = undefined;
77
- this.generatorProcess = this.forkReadSourcesAndProcessSugarWorker();
78
- console.log("Restarted generator");
79
- }
29
+ if (!this.pool) {
30
+ this.pool = new _GeneratorPool.GeneratorPool(this.generatorPath);
80
31
  }
81
- this.generatorProcess.send([this.pathToGeneratorRootDir, formSourcesPath, farmDirectory, generationOptions, this.purgeCache, currentRequestNumber]);
82
- const result = await promise;
83
- this.processSugarDeferredMap.delete(currentRequestNumber);
84
- return result;
32
+ const message = [formSourcesPath, farmDirectory, generationOptions];
33
+ return this.pool.generate(message);
85
34
  }
86
- forkReadSourcesAndProcessSugarWorker() {
87
- const processSugarWorker = (0, _child_process.fork)("./ReadSourcesAndProcessSugarWorker", [], {
88
- cwd: __dirname
89
- });
90
- processSugarWorker.on("message", response => {
91
- const currentDeferred = this.processSugarDeferredMap.get(response.requestNumber);
92
- if (currentDeferred == undefined) {
93
- return;
94
- }
95
- if (response.type === "Error") {
96
- currentDeferred.reject(new Error(response.errorText));
97
- } else {
98
- const formContent = response.generatedForm;
99
- const result = {};
100
- for (const [key, formContentItem] of (0, _IterableUtils.iterateEntries)(formContent)) {
101
- result[key] = typeof formContentItem === "string" ? formContentItem : Buffer.from(formContentItem.payload, formContentItem.encoding);
102
- }
103
- currentDeferred.resolve(result);
104
- }
105
- });
106
- processSugarWorker.on("error", error => {
107
- throw error;
108
- });
109
- return processSugarWorker;
35
+ async dispose() {
36
+ var _this$pool;
37
+ await ((_this$pool = this.pool) === null || _this$pool === void 0 ? void 0 : _this$pool.dispose());
38
+ this.pool = undefined;
110
39
  }
111
40
  }
112
- const generatorsCache = new Map();
113
- function createAsyncGenerator(pathToGeneratorRootDir, purgeCache, useGeneratorRestarting) {
114
- let result = generatorsCache.get(pathToGeneratorRootDir);
115
- if (result == undefined) {
116
- result = new GeneratorAsyncProxy(pathToGeneratorRootDir, purgeCache, useGeneratorRestarting);
117
- generatorsCache.set(pathToGeneratorRootDir, result);
118
- }
119
- return result;
120
- }
41
+ const createAsyncGenerator = generatorPath => new GeneratorAsyncProxy(generatorPath);
42
+ exports.createAsyncGenerator = createAsyncGenerator;
121
43
  //# sourceMappingURL=CreateAsyncGenerator.js.map