@speedkit/cli 2.11.0 → 2.13.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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [2.13.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.12.0...v2.13.0) (2024-03-15)
2
+
3
+
4
+ ### Features
5
+
6
+ * **eslint:** prevent oclif config ([9bde25c](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/9bde25cdcd472e7c314a4b79739355518e76ce94))
7
+
8
+ # [2.12.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.11.0...v2.12.0) (2024-03-15)
9
+
10
+
11
+ ### Features
12
+
13
+ * update readme + package meta data ([85ae548](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/85ae548f1b009efd8c4d2bff9f25fbf9523b4553))
14
+
1
15
  # [2.11.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.10.0...v2.11.0) (2024-03-15)
2
16
 
3
17
 
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
- speed-kit-cli
1
+ @speed-kit/cli
2
2
  =============
3
3
 
4
4
  [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
5
- [![Version](https://img.shields.io/npm/v/speed-kit-cli.svg)](https://npmjs.org/package/speed-kit-cli)
6
- [![Downloads/week](https://img.shields.io/npm/dw/speed-kit-cli.svg)](https://npmjs.org/package/speed-kit-cli)
7
- [![License](https://img.shields.io/npm/l/speed-kit-cli.svg)](https://github.com/baqend/speed-kit-cli/blob/master/package.json)
5
+ [![Node Version](https://img.shields.io/node/v/@speedkit/cli.svg)](https://npmjs.org/package/@speedkit/cli)
6
+ [![NPM Version](https://img.shields.io/npm/v/@speedkit/cli.svg)](https://npmjs.org/package/@speedkit/cli)
7
+ [![Downloads/week](https://img.shields.io/npm/dw/@speedkit/cli.svg)](https://npmjs.org/package/@speedkit/cli)
8
8
 
9
9
  ## Quicklinks
10
10
 
@@ -12,8 +12,6 @@ speed-kit-cli
12
12
  * [Usage](#usage)
13
13
  * [Commands](#commands)
14
14
  <!-- tocstop -->
15
- * [Contributing](./CONTRIBUTING.md)
16
- * [Changelog](./CHANGELOG.md)
17
15
 
18
16
  # Usage
19
17
 
@@ -23,7 +21,7 @@ $ npm install -g @speedkit/cli
23
21
  $ sk COMMAND
24
22
  running command...
25
23
  $ sk (--version)
26
- @speedkit/cli/2.11.0 linux-x64 node-v20.11.1
24
+ @speedkit/cli/2.13.0 linux-x64 node-v20.11.1
27
25
  $ sk --help [COMMAND]
28
26
  USAGE
29
27
  $ sk COMMAND
@@ -59,8 +57,8 @@ On the first execution of any `sk` command a `config.json` will be created and s
59
57
  ### Using Environment Variables
60
58
 
61
59
  By either...
62
- - copying [.env.sample](./.env.sample) as `.env` to the directory of the cloned [sk-onboarding](https://gitlab.orestes.info/baqend/sk-onboarding)
63
- - or by exporting [the listed variables](./.env.sample) to your shell as needed before using a specific CLI command.
60
+ - copying [.env.sample](.env.sample) as `.env` to the directory of the cloned [sk-onboarding](https://gitlab.orestes.info/baqend/sk-onboarding)
61
+ - or by exporting [the listed variables](.env.sample) to your shell as needed before using a specific CLI command.
64
62
 
65
63
  # Commands
66
64
  <!-- commands -->
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AthenaService = void 0;
4
4
  const client_athena_1 = require("@aws-sdk/client-athena");
5
5
  class AthenaService {
6
- client = new client_athena_1.AthenaClient({ region: 'eu-central-1' });
6
+ client = new client_athena_1.AthenaClient({ region: "eu-central-1" });
7
7
  async getUsedPopsPerOrigin(app, useRum) {
8
8
  const query = `
9
9
  with data as (
@@ -13,7 +13,7 @@ class AthenaService {
13
13
  from fastly.logs
14
14
  where date between ? and ?
15
15
  and app = ?
16
- and ${useRum ? 'ispibeacon' : 'isassetrequest and isnavigaterequest'}
16
+ and ${useRum ? "ispibeacon" : "isassetrequest and isnavigaterequest"}
17
17
  and client.bot is null
18
18
  and origin not in('Unknown', '')
19
19
  )
@@ -34,13 +34,13 @@ class AthenaService {
34
34
  const start = startDate.toISOString().slice(0, 10);
35
35
  const end = endDate.toISOString().slice(0, 10);
36
36
  const queryId = await this.runQuery(query, [start, end, app], 12 * 60);
37
- return await this.fetchResult(queryId);
37
+ return (await this.fetchResult(queryId));
38
38
  }
39
39
  castValueToType(value, type) {
40
40
  if (value === null)
41
41
  return null;
42
42
  switch (type) {
43
- case 'bigint': {
43
+ case "bigint": {
44
44
  return Number(value);
45
45
  }
46
46
  default: {
@@ -61,10 +61,13 @@ class AthenaService {
61
61
  do {
62
62
  // Max Results can be set but if its not set,
63
63
  // it will choose the maximum page size.
64
- const command = new client_athena_1.GetQueryResultsCommand({ NextToken, QueryExecutionId: queryId });
64
+ const command = new client_athena_1.GetQueryResultsCommand({
65
+ NextToken,
66
+ QueryExecutionId: queryId,
67
+ });
65
68
  const result = await this.client.send(command);
66
- const columns = result.ResultSet.ResultSetMetadata.ColumnInfo.map(info => info.Name);
67
- const types = result.ResultSet.ResultSetMetadata.ColumnInfo.map(info => info.Type);
69
+ const columns = result.ResultSet.ResultSetMetadata.ColumnInfo.map((info) => info.Name);
70
+ const types = result.ResultSet.ResultSetMetadata.ColumnInfo.map((info) => info.Type);
68
71
  for (const rowRaw of result.ResultSet.Rows) {
69
72
  if (first) {
70
73
  first = false;
@@ -90,11 +93,11 @@ class AthenaService {
90
93
  * @return The query id which can be used to fetch the query results
91
94
  */
92
95
  async runQuery(sql, parameters, useCacheTTLMinutes = 60) {
93
- const ExecutionParameters = parameters.map(value => typeof value === 'string' ? `'${value}'` : String(value));
96
+ const ExecutionParameters = parameters.map((value) => typeof value === "string" ? `'${value}'` : String(value));
94
97
  const command = new client_athena_1.StartQueryExecutionCommand({
95
98
  ExecutionParameters,
96
99
  QueryExecutionContext: {
97
- Catalog: 'live',
100
+ Catalog: "live",
98
101
  },
99
102
  QueryString: sql,
100
103
  ResultReuseConfiguration: {
@@ -109,7 +112,7 @@ class AthenaService {
109
112
  return response.QueryExecutionId;
110
113
  }
111
114
  async sleep(sleep) {
112
- return new Promise(resolve => {
115
+ return new Promise((resolve) => {
113
116
  setTimeout(resolve, sleep);
114
117
  });
115
118
  }
@@ -120,10 +123,11 @@ class AthenaService {
120
123
  const status = result.QueryExecution.Status;
121
124
  switch (status.State) {
122
125
  case client_athena_1.QueryExecutionState.FAILED: {
123
- throw new Error('The Amazon Athena query failed to run with error message: ' + status.StateChangeReason);
126
+ throw new Error("The Amazon Athena query failed to run with error message: " +
127
+ status.StateChangeReason);
124
128
  }
125
129
  case client_athena_1.QueryExecutionState.CANCELLED: {
126
- throw new Error('The Amazon Athena query was cancelled.');
130
+ throw new Error("The Amazon Athena query was cancelled.");
127
131
  }
128
132
  case client_athena_1.QueryExecutionState.SUCCEEDED: {
129
133
  return;
@@ -1,5 +1,5 @@
1
- import { EntityManager } from 'baqend';
2
- import Install from '../models/install';
1
+ import { EntityManager } from "baqend";
2
+ import Install from "../models/install";
3
3
  export default class ConfigApiService {
4
4
  private db;
5
5
  private readonly app;
@@ -14,5 +14,5 @@ export default class ConfigApiService {
14
14
  saveRemoteModule(moduleCode: string, moduleName: string): Promise<string>;
15
15
  getRemoteServerConfig(): Promise<string>;
16
16
  saveRemoteServerConfig(localPath: string, configurationVersion: string): Promise<void>;
17
- fetchAndGetBody(url: string, requestInit?: {}): Promise<any>;
17
+ fetchAndGetBody(url: string, requestInit?: NonNullable<unknown>): Promise<any>;
18
18
  }
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const fs = tslib_1.__importStar(require("fs-extra"));
5
- const fetch = require('node-fetch');
6
- const https = require('https');
7
- const agent = new https.Agent({
5
+ const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
6
+ const https_1 = tslib_1.__importDefault(require("https"));
7
+ const agent = new https_1.default.Agent({
8
8
  rejectUnauthorized: false,
9
9
  keepAlive: true,
10
10
  });
@@ -18,11 +18,11 @@ class ConfigApiService {
18
18
  this.app = app;
19
19
  this.requestInit = {
20
20
  agent,
21
- method: 'GET',
21
+ method: "GET",
22
22
  headers: {
23
23
  Host: `${this.app}.app.baqend.com`,
24
24
  authorization: `BAT ${this.db.token}`,
25
- 'Content-Type': 'application/json;charset=UTF-8',
25
+ "Content-Type": "application/json;charset=UTF-8",
26
26
  },
27
27
  timeout: 10_000,
28
28
  };
@@ -34,58 +34,70 @@ class ConfigApiService {
34
34
  }
35
35
  async activateInstall(install) {
36
36
  const activateUrl = `https://${this.app}.app.baqend.com/v1/speedkit/installation/${install.domain}/${install.configVersion}/activate`;
37
- const postInit = Object.assign({}, this.requestInit, { body: '{}', method: 'POST' });
37
+ const postInit = Object.assign({}, this.requestInit, {
38
+ body: "{}",
39
+ method: "POST",
40
+ });
38
41
  return (await this.fetchAndGetBody(activateUrl, postInit));
39
42
  }
40
43
  // Update live version with the osk local body
41
44
  async updateInstall(install) {
42
- const postInit = Object.assign({}, this.requestInit, { body: JSON.stringify(install), method: 'PUT' });
45
+ const postInit = Object.assign({}, this.requestInit, {
46
+ body: JSON.stringify(install),
47
+ method: "PUT",
48
+ });
43
49
  const updateUrl = `https://${this.app}.app.baqend.com/v1/speedkit/installation/${install.domain}/${install.configVersion}`;
44
50
  return (await this.fetchAndGetBody(updateUrl, postInit));
45
51
  }
46
52
  async createNewInstall(domain, origins) {
47
- const postInit = Object.assign({}, this.requestInit, { body: `{origins: ${JSON.stringify(origins)}}`, method: 'POST' });
53
+ const postInit = Object.assign({}, this.requestInit, {
54
+ body: `{origins: ${JSON.stringify(origins)}}`,
55
+ method: "POST",
56
+ });
48
57
  const updateUrl = `https://${this.app}.app.baqend.com/v1/speedkit/installation/${domain}`;
49
58
  const body = await this.fetchAndGetBody(updateUrl, postInit);
50
59
  return body;
51
60
  }
52
61
  async cloneInstall(install) {
53
- const postInit = Object.assign({}, this.requestInit, { body: '{}', method: 'POST' });
62
+ const postInit = Object.assign({}, this.requestInit, {
63
+ body: "{}",
64
+ method: "POST",
65
+ });
54
66
  const cloneUrl = `https://${this.app}.app.baqend.com/v1/speedkit/installation/${install.domain}/${install.configVersion}/clone`;
55
67
  const body = await this.fetchAndGetBody(cloneUrl, postInit);
56
68
  return body;
57
69
  }
58
70
  async getRemoteModule(moduleName) {
59
- return await this.db.code.loadCode(moduleName, 'module');
71
+ return await this.db.code.loadCode(moduleName, "module");
60
72
  }
61
73
  async saveRemoteModule(moduleCode, moduleName) {
62
- return await this.db.code.saveCode(moduleName, 'module', moduleCode);
74
+ return await this.db.code.saveCode(moduleName, "module", moduleCode);
63
75
  }
64
76
  async getRemoteServerConfig() {
65
77
  const urlPath = `https://${this.app}.app.baqend.com/v1/config`;
66
78
  const body = await this.fetchAndGetBody(urlPath);
67
- return JSON.stringify(body, null, '\t');
79
+ return JSON.stringify(body, null, "\t");
68
80
  }
69
81
  async saveRemoteServerConfig(localPath, configurationVersion) {
70
- const localServerConfigContent = fs.readFileSync(localPath, 'utf-8');
82
+ const localServerConfigContent = fs.readFileSync(localPath, "utf-8");
71
83
  const localServerConfig = JSON.parse(localServerConfigContent);
72
84
  localServerConfig.revision.version = configurationVersion;
73
85
  const urlPath = `https://${this.app}.app.baqend.com/v1/config`;
74
86
  const putInit = Object.assign({}, this.requestInit, {
75
87
  body: JSON.stringify(localServerConfig),
76
- method: 'PUT',
88
+ method: "PUT",
77
89
  headers: {
78
90
  Host: `${this.app}.app.baqend.com`,
79
91
  // Origin: "origin",
80
92
  authorization: `BAT ${this.db.token}`,
81
- 'Content-Type': 'application/json',
82
- 'If-Match': configurationVersion,
93
+ "Content-Type": "application/json",
94
+ "If-Match": configurationVersion,
83
95
  },
84
96
  });
85
97
  await this.fetchAndGetBody(urlPath, putInit);
86
98
  }
87
99
  async fetchAndGetBody(url, requestInit = this.requestInit) {
88
- const res = await fetch(url, requestInit);
100
+ const res = await (0, node_fetch_1.default)(url, requestInit);
89
101
  const body = await res.json();
90
102
  if (res.status !== 200) {
91
103
  throw new Error(body.message);
@@ -17,14 +17,14 @@ class DiffService {
17
17
  this.diffExecutableTemplate = diffExecutableTemplate;
18
18
  }
19
19
  async diff(localPath, fileName, tmpContent) {
20
- let tmpFilePath = await this.writeContentToTemporalFile(fileName, tmpContent);
20
+ const tmpFilePath = await this.writeContentToTemporalFile(fileName, tmpContent);
21
21
  return await this.executeDiff(tmpFilePath, localPath);
22
22
  }
23
23
  async diffContent(fileName, localContent, remoteContent) {
24
- let tmpLocalFilePath = await this.writeContentToTemporalFile(`${fileName}-local`, localContent);
25
- let tmpRemoteFilePath = await this.writeContentToTemporalFile(`${fileName}-remote`, remoteContent);
24
+ const tmpLocalFilePath = await this.writeContentToTemporalFile(`${fileName}-local`, localContent);
25
+ const tmpRemoteFilePath = await this.writeContentToTemporalFile(`${fileName}-remote`, remoteContent);
26
26
  const diff = await this.executeDiff(tmpLocalFilePath, tmpRemoteFilePath);
27
- const changedFile = await (0, promises_1.readFile)(tmpLocalFilePath, 'utf-8');
27
+ const changedFile = await (0, promises_1.readFile)(tmpLocalFilePath, "utf-8");
28
28
  return { changedFile, diff };
29
29
  }
30
30
  /**
@@ -36,17 +36,17 @@ class DiffService {
36
36
  this.tempPath = await (0, file_helper_1.createTemporalDir)();
37
37
  }
38
38
  if (!this.tempPath) {
39
- this.cli.writeError('No temporary Directory found and unable to create a new temporary Directory');
39
+ this.cli.writeError("No temporary Directory found and unable to create a new temporary Directory");
40
40
  this.cli.exit(1);
41
41
  }
42
42
  return this.tempPath;
43
43
  }
44
44
  async writeContentToTemporalFile(tempFileName, content) {
45
45
  if (!content) {
46
- content = 'No file was found';
46
+ content = "No file was found";
47
47
  }
48
- const resolveFilePath = path_1.default.join(await this.getTemporalDirectoryPath() + `/${tempFileName}`);
49
- await promises_1.default.writeFile(resolveFilePath, content.replace(/\r?\n/gm, '\n'));
48
+ const resolveFilePath = path_1.default.join((await this.getTemporalDirectoryPath()) + `/${tempFileName}`);
49
+ await promises_1.default.writeFile(resolveFilePath, content.replace(/\r?\n/gm, "\n"));
50
50
  return resolveFilePath;
51
51
  }
52
52
  /**
@@ -55,9 +55,9 @@ class DiffService {
55
55
  * @description removes whitespaces, newlines and compares both params content for equality.
56
56
  * @return returns true if both localContent and remoteContent are equal otherwise returns false.
57
57
  */
58
- isContentEqual(localContent = '', remoteContent = '') {
59
- const trimLocalContent = localContent.replace(/[\n\r\s]/g, '');
60
- const trimRemoteContent = remoteContent.replace(/[\n\r\s]/g, '');
58
+ isContentEqual(localContent = "", remoteContent = "") {
59
+ const trimLocalContent = localContent.replace(/[\n\r\s]/g, "");
60
+ const trimRemoteContent = remoteContent.replace(/[\n\r\s]/g, "");
61
61
  return trimLocalContent === trimRemoteContent;
62
62
  }
63
63
  /**
@@ -72,13 +72,19 @@ class DiffService {
72
72
  let localContent;
73
73
  let remoteContent;
74
74
  try {
75
- localContent = await promises_1.default.readFile(localPath, { encoding: 'utf8', flag: 'r' });
75
+ localContent = await promises_1.default.readFile(localPath, {
76
+ encoding: "utf8",
77
+ flag: "r",
78
+ });
76
79
  }
77
80
  catch (error) {
78
81
  return false;
79
82
  }
80
83
  try {
81
- remoteContent = await promises_1.default.readFile(remotePath, { encoding: 'utf8', flag: 'r' });
84
+ remoteContent = await promises_1.default.readFile(remotePath, {
85
+ encoding: "utf8",
86
+ flag: "r",
87
+ });
82
88
  }
83
89
  catch (error) {
84
90
  this.cli.writeError(`Error reading remote file ${remoteContent}: ${error.message}`);
@@ -92,20 +98,22 @@ class DiffService {
92
98
  return false;
93
99
  }
94
100
  // try custom diff tool
95
- if (this.diffExecutablePath !== null && this.diffExecutablePath.length > 0 && this.diffExecutableTemplate !== null) {
101
+ if (this.diffExecutablePath !== null &&
102
+ this.diffExecutablePath.length > 0 &&
103
+ this.diffExecutableTemplate !== null) {
96
104
  try {
97
105
  const command = this.diffExecutableTemplate
98
106
  .replace("$exec", this.diffExecutablePath)
99
107
  .replace("$file1", localPath)
100
108
  .replace("$file2", remotePath);
101
- (0, child_process_1.execSync)(command, { stdio: 'pipe' });
109
+ (0, child_process_1.execSync)(command, { stdio: "pipe" });
102
110
  }
103
111
  catch (error) {
104
112
  this.cli.code(error.stdout.toString());
105
113
  }
106
114
  return false;
107
115
  }
108
- let isWindows = process.platform.startsWith('win');
116
+ const isWindows = process.platform.startsWith("win");
109
117
  let ideaCommandAvailable;
110
118
  try {
111
119
  (0, child_process_1.execSync)(`idea diff "${localPath}" "${remotePath}"`);
@@ -117,10 +125,10 @@ class DiffService {
117
125
  try {
118
126
  if (!ideaCommandAvailable) {
119
127
  if (isWindows) {
120
- (0, child_process_1.execSync)(`"%IDEA_INITIAL_DIRECTORY%\\idea" diff ${localPath} ${remotePath}`, { stdio: 'pipe' });
128
+ (0, child_process_1.execSync)(`"%IDEA_INITIAL_DIRECTORY%\\idea" diff ${localPath} ${remotePath}`, { stdio: "pipe" });
121
129
  }
122
130
  else {
123
- (0, child_process_1.execSync)(`"$IDEA_INITIAL_DIRECTORY/idea" diff ${localPath} ${remotePath}`, { stdio: 'pipe' });
131
+ (0, child_process_1.execSync)(`"$IDEA_INITIAL_DIRECTORY/idea" diff ${localPath} ${remotePath}`, { stdio: "pipe" });
124
132
  }
125
133
  }
126
134
  return false;
@@ -1,3 +1,3 @@
1
- export * from './diff-service';
2
- export * from './diff-service-factory';
3
- export * from './diff-model';
1
+ export * from "./diff-service";
2
+ export * from "./diff-service-factory";
3
+ export * from "./diff-model";
@@ -1,4 +1,4 @@
1
- import { CliService } from './cli';
1
+ import { CliService } from "./cli";
2
2
  export declare class DiffService {
3
3
  private cli;
4
4
  private tempPath;
@@ -21,17 +21,17 @@ class DiffService {
21
21
  this.tempPath = await (0, file_helper_1.createTemporalDir)();
22
22
  }
23
23
  if (!this.tempPath) {
24
- this.cli.writeError('No temporary Directory found and unable to create a new temporary Directory');
24
+ this.cli.writeError("No temporary Directory found and unable to create a new temporary Directory");
25
25
  this.cli.exit(1);
26
26
  }
27
27
  return this.tempPath;
28
28
  }
29
29
  async writeContentToTemporalFile(tempFileName, content) {
30
30
  if (!content) {
31
- content = 'No file was found';
31
+ content = "No file was found";
32
32
  }
33
- const resolveFilePath = path_1.default.join(await this.getTemporalDirectoryPath() + `/${tempFileName}`);
34
- await fs.writeFile(resolveFilePath, content.replace(/\r?\n/gm, '\n'));
33
+ const resolveFilePath = path_1.default.join((await this.getTemporalDirectoryPath()) + `/${tempFileName}`);
34
+ await fs.writeFile(resolveFilePath, content.replace(/\r?\n/gm, "\n"));
35
35
  return resolveFilePath;
36
36
  }
37
37
  /**
@@ -39,14 +39,14 @@ class DiffService {
39
39
  * @param content
40
40
  */
41
41
  trimContent(content) {
42
- return content.replace(/[\n\r\s]/g, '');
42
+ return content.replace(/[\n\r\s]/g, "");
43
43
  }
44
44
  /**
45
45
  * @param content1
46
46
  * @param content2
47
47
  * @return returns true if both contents are equal otherwise returns false.
48
48
  */
49
- isContentEqual(content1 = '', content2 = '') {
49
+ isContentEqual(content1 = "", content2 = "") {
50
50
  return this.trimContent(content1) === this.trimContent(content2);
51
51
  }
52
52
  async shouldDeployModule(moduleName, remoteModule, localFilePath) {
@@ -63,14 +63,14 @@ class DiffService {
63
63
  let content1;
64
64
  let content2;
65
65
  try {
66
- content1 = await fs.readFile(filePath1, { encoding: 'utf8', flag: 'r' });
66
+ content1 = await fs.readFile(filePath1, { encoding: "utf8", flag: "r" });
67
67
  }
68
68
  catch (error) {
69
69
  this.cli.writeError(`Error reading ${path_1.default.basename(filePath1)}: ${error.message}`);
70
70
  this.cli.exit(1);
71
71
  }
72
72
  try {
73
- content2 = await fs.readFile(filePath2, { encoding: 'utf8', flag: 'r' });
73
+ content2 = await fs.readFile(filePath2, { encoding: "utf8", flag: "r" });
74
74
  }
75
75
  catch (error) {
76
76
  this.cli.writeError(`Error reading ${path_1.default.basename(filePath2)}: ${error.message}`);
@@ -83,10 +83,10 @@ class DiffService {
83
83
  else if (hide) {
84
84
  return true;
85
85
  }
86
- let isWindows = process.platform.startsWith('win');
86
+ const isWindows = process.platform.startsWith("win");
87
87
  let ideaCommandAvailable;
88
88
  try {
89
- (0, child_process_1.execSync)(`idea diff "${filePath1}" "${filePath2}"`, { stdio: 'pipe' });
89
+ (0, child_process_1.execSync)(`idea diff "${filePath1}" "${filePath2}"`, { stdio: "pipe" });
90
90
  ideaCommandAvailable = true;
91
91
  }
92
92
  catch {
@@ -95,10 +95,10 @@ class DiffService {
95
95
  try {
96
96
  if (!ideaCommandAvailable) {
97
97
  if (isWindows) {
98
- (0, child_process_1.execSync)(`"%IDEA_INITIAL_DIRECTORY%\\idea" diff ${filePath1} ${filePath2}`, { stdio: 'pipe' });
98
+ (0, child_process_1.execSync)(`"%IDEA_INITIAL_DIRECTORY%\\idea" diff ${filePath1} ${filePath2}`, { stdio: "pipe" });
99
99
  }
100
100
  else {
101
- (0, child_process_1.execSync)(`"$IDEA_INITIAL_DIRECTORY/idea" diff ${filePath1} ${filePath2}`, { stdio: 'pipe' });
101
+ (0, child_process_1.execSync)(`"$IDEA_INITIAL_DIRECTORY/idea" diff ${filePath1} ${filePath2}`, { stdio: "pipe" });
102
102
  }
103
103
  }
104
104
  }
@@ -17,6 +17,6 @@ export declare class SpeedKitInstallContext {
17
17
  * @returns {Promise<string>} a Promise which resolves to the latest dynamic fetcher
18
18
  */
19
19
  bundleDynamicFetcher(): Promise<string>;
20
- getSpeedKitInstallJs(): Promise<string>;
21
20
  private getConfigSpeedKit;
21
+ getSpeedKitInstallJs(): Promise<string>;
22
22
  }
@@ -42,16 +42,32 @@ class SpeedKitInstallContext {
42
42
  target: "es6",
43
43
  });
44
44
  }
45
+ getConfigSpeedKit() {
46
+ const configString = this.files
47
+ .getByName(files_1.INTEGRATION_FILES.CONFIG.SPEED_KIT)
48
+ .getContent();
49
+ if (!this.isLocalRuntime) {
50
+ return configString;
51
+ }
52
+ if (configString.includes("delayRacedOrigin")) {
53
+ return configString.replace(/delayRacedOrigin:[^\d,|](\d*)[^,]*,/, (config, value) => {
54
+ return config.replace(value, "100");
55
+ });
56
+ }
57
+ return configString.replace(/window\.speedKit[^{]*=[^{]*{/, (configOpenTag) => {
58
+ return configOpenTag + `\n delayRacedOrigin: 100,\n`;
59
+ });
60
+ }
45
61
  async getSpeedKitInstallJs() {
46
62
  const configJs = this.skTemplate.render({
47
63
  config: this.getConfigSpeedKit(),
64
+ forceInstall: this.customerConfig.forceInstall,
65
+ installPath: this.customerConfig.installPath,
66
+ installParams: this.customerConfig.installParams,
67
+ domain: this.customerConfig.domain,
48
68
  df: this.files
49
69
  .getByName(files_1.INTEGRATION_FILES.CUSTOM.DYNAMIC_FETCHER)
50
70
  .getContent(),
51
- domain: this.customerConfig.domain,
52
- forceInstall: this.customerConfig.forceInstall,
53
- installParams: this.customerConfig.installParams,
54
- installPath: this.customerConfig.installPath,
55
71
  });
56
72
  return this.bundler.bundle({
57
73
  basePaths: IMPORT_PATHS,
@@ -70,21 +86,5 @@ class SpeedKitInstallContext {
70
86
  logLevel: "error",
71
87
  });
72
88
  }
73
- getConfigSpeedKit() {
74
- const configString = this.files
75
- .getByName(files_1.INTEGRATION_FILES.CONFIG.SPEED_KIT)
76
- .getContent();
77
- if (!this.isLocalRuntime) {
78
- return configString;
79
- }
80
- if (configString.includes("delayRacedOrigin")) {
81
- return configString.replace(/delayRacedOrigin:[^\d,|](\d*)[^,]*,/, (config, value) => {
82
- return config.replace(value, "100");
83
- });
84
- }
85
- return configString.replace(/window\.speedKit[^{]*=[^{]*{/, (configOpenTag) => {
86
- return configOpenTag + `\n delayRacedOrigin: 100,\n`;
87
- });
88
- }
89
89
  }
90
90
  exports.SpeedKitInstallContext = SpeedKitInstallContext;
@@ -1,3 +1,3 @@
1
- export * from './pull-service-model';
2
- export * from './pull-service-factory';
3
- export * from './pull-service';
1
+ export * from "./pull-service-model";
2
+ export * from "./pull-service-factory";
3
+ export * from "./pull-service";
@@ -4,7 +4,7 @@ exports.InstallResourceToFileMapping = exports.PullContext = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const dotenv = tslib_1.__importStar(require("dotenv"));
6
6
  dotenv.config();
7
- const DEFAULT_CONFIG_NAME = 'production';
7
+ const DEFAULT_CONFIG_NAME = "production";
8
8
  class PullContext {
9
9
  customerPath;
10
10
  configName;
@@ -15,13 +15,16 @@ class PullContext {
15
15
  }
16
16
  exports.PullContext = PullContext;
17
17
  exports.InstallResourceToFileMapping = {
18
- 'config': { fileName: "config_SpeedKit", extension: "js" },
19
- 'documentHandlerConfig': { fileName: "config_documentHandler", extension: "js" },
20
- 'dynamicFetcherConfig': { fileName: "config_dynamicBlocks", extension: "es6" },
21
- 'custom': { fileName: "config_loadHandler", extension: "js" },
22
- 'loader': { fileName: "custom_loader", extension: "js" },
23
- 'sw': { fileName: "custom_sw", extension: "js" },
24
- 'documentHandler': { fileName: "custom_documentHandler", extension: "js" },
25
- 'dynamicFetcher': { fileName: "custom_dynamicFetcher", extension: "js" },
26
- 'customStyle': { fileName: "config_dynamicStyles", extension: "css" },
18
+ config: { fileName: "config_SpeedKit", extension: "js" },
19
+ documentHandlerConfig: {
20
+ fileName: "config_documentHandler",
21
+ extension: "js",
22
+ },
23
+ dynamicFetcherConfig: { fileName: "config_dynamicBlocks", extension: "es6" },
24
+ custom: { fileName: "config_loadHandler", extension: "js" },
25
+ loader: { fileName: "custom_loader", extension: "js" },
26
+ sw: { fileName: "custom_sw", extension: "js" },
27
+ documentHandler: { fileName: "custom_documentHandler", extension: "js" },
28
+ dynamicFetcher: { fileName: "custom_dynamicFetcher", extension: "js" },
29
+ customStyle: { fileName: "config_dynamicStyles", extension: "css" },
27
30
  };
@@ -44,22 +44,25 @@ class PullService {
44
44
  }
45
45
  async updateLocalFileByInstallResource(installResource, key) {
46
46
  const installResourceContent = installResource[key];
47
- const fileName = _1.InstallResourceToFileMapping[key]['fileName'];
48
- const extension = _1.InstallResourceToFileMapping[key]['extension'];
47
+ const fileName = _1.InstallResourceToFileMapping[key]["fileName"];
48
+ const extension = _1.InstallResourceToFileMapping[key]["extension"];
49
49
  // local and remote are empty. skip
50
- if (this.isEmpty(installResourceContent) && !this.fileList.hasFile(fileName)) {
50
+ if (this.isEmpty(installResourceContent) &&
51
+ !this.fileList.hasFile(fileName)) {
51
52
  this.cli.writeSuccess(`empty, skip: ${fileName}`);
52
53
  return;
53
54
  }
54
55
  // local file doesn't exist. create it
55
- if (!this.isEmpty(installResourceContent) && !this.fileList.hasFile(fileName)) {
56
+ if (!this.isEmpty(installResourceContent) &&
57
+ !this.fileList.hasFile(fileName)) {
56
58
  this.cli.writeSuccess(`create: ${fileName}`);
57
59
  await this.createFile(fileName, extension, installResourceContent, key);
58
60
  return;
59
61
  }
60
62
  const file = this.readLocalFile(fileName);
61
63
  // local file exists but remote is empty. delete
62
- if (this.isEmpty(installResourceContent) && this.fileList.hasFile(fileName)) {
64
+ if (this.isEmpty(installResourceContent) &&
65
+ this.fileList.hasFile(fileName)) {
63
66
  this.cli.writeError(`delete: ${fileName}`);
64
67
  await file.delete();
65
68
  return;
@@ -89,7 +92,10 @@ class PullService {
89
92
  await resourceFile.updateFile();
90
93
  }
91
94
  hasGitChanges() {
92
- const customerName = this.basePath.split('/').filter((value) => value.length > 0).pop();
95
+ const customerName = this.basePath
96
+ .split("/")
97
+ .filter((value) => value.length > 0)
98
+ .pop();
93
99
  try {
94
100
  const stdoutBuffer = (0, child_process_1.execSync)("git diff --name-status");
95
101
  const stdout = stdoutBuffer.toString("utf8");
@@ -696,5 +696,5 @@
696
696
  ]
697
697
  }
698
698
  },
699
- "version": "2.11.0"
699
+ "version": "2.13.0"
700
700
  }
package/package.json CHANGED
@@ -1,14 +1,20 @@
1
1
  {
2
2
  "name": "@speedkit/cli",
3
3
  "description": "Speed Kit CLI",
4
- "version": "2.11.0",
4
+ "version": "2.13.0",
5
5
  "author": {
6
6
  "name": "Baqend.com",
7
7
  "email": "info@baqend.com"
8
8
  },
9
- "repository": "https://gitlab.orestes.info/baqend/speed-kit-cli",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://gitlab.orestes.info/baqend/speed-kit-cli.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://www.notion.so/baqend/d3749c5796d647f5892aa5ebfa2fd75f?v=002e4f2c19af4b50a590c093fd82afed",
15
+ "email": "info@baqend.com"
16
+ },
10
17
  "homepage": "https://gitlab.orestes.info/baqend/speed-kit-cli",
11
- "bugs": "https://www.notion.so/baqend/d3749c5796d647f5892aa5ebfa2fd75f?v=002e4f2c19af4b50a590c093fd82afed",
12
18
  "license": "MIT",
13
19
  "publishConfig": {
14
20
  "access": "public"