@equinor/echo-cli 1.0.1 → 1.0.3-beta-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/package.json +2 -2
- package/templates/echoAppTemplate/src/app.module.css +5 -5
- package/templates/echoAppTemplate/src/app.tsx +30 -30
- package/templates/echoAppTemplate/src/index.ts +6 -6
- package/templates/echoAppTemplateTutorial/src/app.module.css +5 -5
- package/templates/echoAppTemplateTutorial/src/app.tsx +30 -30
- package/templates/echoAppTemplateTutorial/src/index.ts +6 -6
- package/templates/echoLibraryTemplate/public/style.css +43 -43
- package/templates/echoPluginTemplate/public/style.css +43 -43
- package/lib/__test__/utils/merg.test.d.ts +0 -1
- package/lib/__test__/utils/merg.test.js +0 -29
- package/lib/__test__/utils/merg.test.js.map +0 -1
- package/lib/config/common/buildAndCopyEchoHostForProd.d.ts +0 -16
- package/lib/config/common/buildAndCopyEchoHostForProd.js +0 -38
- package/lib/config/common/buildAndCopyEchoHostForProd.js.map +0 -1
- package/lib/config/common/copyFile.d.ts +0 -2
- package/lib/config/common/copyFile.js +0 -10
- package/lib/config/common/copyFile.js.map +0 -1
- package/lib/config/common/echoManifest.d.ts +0 -3
- package/lib/config/common/echoManifest.js +0 -45
- package/lib/config/common/echoManifest.js.map +0 -1
- package/lib/config/common/echoModuleConfig.d.ts +0 -31
- package/lib/config/common/echoModuleConfig.js +0 -34
- package/lib/config/common/echoModuleConfig.js.map +0 -1
- package/lib/config/common/echoModuleId.d.ts +0 -5
- package/lib/config/common/echoModuleId.js +0 -15
- package/lib/config/common/echoModuleId.js.map +0 -1
- package/lib/config/common/extensions.d.ts +0 -1
- package/lib/config/common/extensions.js +0 -2
- package/lib/config/common/extensions.js.map +0 -1
- package/lib/config/common/getCurrentIndexFile.d.ts +0 -2
- package/lib/config/common/getCurrentIndexFile.js +0 -11
- package/lib/config/common/getCurrentIndexFile.js.map +0 -1
- package/lib/config/common/getPackageJson.d.ts +0 -1
- package/lib/config/common/getPackageJson.js +0 -7
- package/lib/config/common/getPackageJson.js.map +0 -1
- package/lib/config/common/https.d.ts +0 -6
- package/lib/config/common/https.js +0 -16
- package/lib/config/common/https.js.map +0 -1
- package/lib/config/common/initOptions.d.ts +0 -26
- package/lib/config/common/initOptions.js +0 -32
- package/lib/config/common/initOptions.js.map +0 -1
- package/lib/config/common/ssl.d.ts +0 -7
- package/lib/config/common/ssl.js +0 -76
- package/lib/config/common/ssl.js.map +0 -1
- package/lib/config/common/updateEnv.d.ts +0 -6
- package/lib/config/common/updateEnv.js +0 -16
- package/lib/config/common/updateEnv.js.map +0 -1
- package/lib/config/webpack/config.d.ts +0 -3
- package/lib/config/webpack/config.js +0 -36
- package/lib/config/webpack/config.js.map +0 -1
- package/lib/config/webpack/configBuilders/devServer.d.ts +0 -8
- package/lib/config/webpack/configBuilders/devServer.js +0 -60
- package/lib/config/webpack/configBuilders/devServer.js.map +0 -1
- package/lib/config/webpack/configBuilders/entry.d.ts +0 -12
- package/lib/config/webpack/configBuilders/entry.js +0 -13
- package/lib/config/webpack/configBuilders/entry.js.map +0 -1
- package/lib/config/webpack/configBuilders/module.d.ts +0 -8
- package/lib/config/webpack/configBuilders/module.js +0 -124
- package/lib/config/webpack/configBuilders/module.js.map +0 -1
- package/lib/config/webpack/configBuilders/optimization.d.ts +0 -7
- package/lib/config/webpack/configBuilders/optimization.js +0 -30
- package/lib/config/webpack/configBuilders/optimization.js.map +0 -1
- package/lib/config/webpack/configBuilders/output.d.ts +0 -12
- package/lib/config/webpack/configBuilders/output.js +0 -20
- package/lib/config/webpack/configBuilders/output.js.map +0 -1
- package/lib/config/webpack/configBuilders/plugins.d.ts +0 -10
- package/lib/config/webpack/configBuilders/plugins.js +0 -29
- package/lib/config/webpack/configBuilders/plugins.js.map +0 -1
- package/lib/config/webpack/echoWebpackModule.d.ts +0 -2
- package/lib/config/webpack/echoWebpackModule.js +0 -47
- package/lib/config/webpack/echoWebpackModule.js.map +0 -1
- package/lib/config/webpack/server.d.ts +0 -3
- package/lib/config/webpack/server.js +0 -22
- package/lib/config/webpack/server.js.map +0 -1
- package/lib/const/common.d.ts +0 -6
- package/lib/const/common.js +0 -15
- package/lib/const/common.js.map +0 -1
- package/lib/echo-build-dev-host.d.ts +0 -6
- package/lib/echo-build-dev-host.js +0 -19
- package/lib/echo-build-dev-host.js.map +0 -1
- package/lib/echo-build.d.ts +0 -34
- package/lib/echo-build.js +0 -83
- package/lib/echo-build.js.map +0 -1
- package/lib/echo-create.d.ts +0 -16
- package/lib/echo-create.js +0 -35
- package/lib/echo-create.js.map +0 -1
- package/lib/echo-dev-host/.env +0 -29
- package/lib/echo-dev-host/README.md +0 -121
- package/lib/echo-dev-host/babel.config.js +0 -11
- package/lib/echo-dev-host/env.sh +0 -51
- package/lib/echo-dev-host/jest.config.js +0 -21
- package/lib/echo-dev-host/package-lock.json +0 -12464
- package/lib/echo-dev-host/package.json +0 -80
- package/lib/echo-dev-host/public/env-config.js +0 -17
- package/lib/echo-dev-host/public/index.css +0 -60
- package/lib/echo-dev-host/public/index.html +0 -21
- package/lib/echo-dev-host/src/api/api-plants.ts +0 -22
- package/lib/echo-dev-host/src/app.css +0 -12
- package/lib/echo-dev-host/src/app.tsx +0 -43
- package/lib/echo-dev-host/src/components/Home/Home.tsx +0 -23
- package/lib/echo-dev-host/src/components/Home/home.module.css +0 -38
- package/lib/echo-dev-host/src/components/dummySearchPanel/DummySearchPanel.tsx +0 -28
- package/lib/echo-dev-host/src/components/dummySearchPanel/dummySearchPanel.module.css +0 -13
- package/lib/echo-dev-host/src/components/legend.tsx +0 -3
- package/lib/echo-dev-host/src/images/frontpage-brand-placeholder.jpg +0 -0
- package/lib/echo-dev-host/src/index.tsx +0 -91
- package/lib/echo-dev-host/src/setupTests.ts +0 -25
- package/lib/echo-dev-host/src/utils/plants.test.ts +0 -33
- package/lib/echo-dev-host/src/utils/plants.ts +0 -12
- package/lib/echo-dev-host/src/utils/setupSkipAuth.ts +0 -43
- package/lib/echo-dev-host/tsconfig.json +0 -21
- package/lib/echo-dev-host/webpack.config.js +0 -145
- package/lib/echo-manifest.d.ts +0 -6
- package/lib/echo-manifest.js +0 -13
- package/lib/echo-manifest.js.map +0 -1
- package/lib/echo-update-dev-host-deps.d.ts +0 -33
- package/lib/echo-update-dev-host-deps.js +0 -186
- package/lib/echo-update-dev-host-deps.js.map +0 -1
- package/lib/tools/buildScripts/buildAndCopyDevHost.d.ts +0 -29
- package/lib/tools/buildScripts/buildAndCopyDevHost.js +0 -135
- package/lib/tools/buildScripts/buildAndCopyDevHost.js.map +0 -1
- package/lib/tools/buildScripts/webpackBuilds.d.ts +0 -3
- package/lib/tools/buildScripts/webpackBuilds.js +0 -87
- package/lib/tools/buildScripts/webpackBuilds.js.map +0 -1
- package/lib/tools/create/copyFile.d.ts +0 -2
- package/lib/tools/create/copyFile.js +0 -16
- package/lib/tools/create/copyFile.js.map +0 -1
- package/lib/tools/create/createProject.d.ts +0 -2
- package/lib/tools/create/createProject.js +0 -83
- package/lib/tools/create/createProject.js.map +0 -1
- package/lib/tools/create/createSetTargetDirectory.d.ts +0 -1
- package/lib/tools/create/createSetTargetDirectory.js +0 -12
- package/lib/tools/create/createSetTargetDirectory.js.map +0 -1
- package/lib/tools/create/getAppTemplateName.d.ts +0 -1
- package/lib/tools/create/getAppTemplateName.js +0 -22
- package/lib/tools/create/getAppTemplateName.js.map +0 -1
- package/lib/tools/create/gitInit.d.ts +0 -1
- package/lib/tools/create/gitInit.js +0 -19
- package/lib/tools/create/gitInit.js.map +0 -1
- package/lib/tools/create/promptOptions.d.ts +0 -2
- package/lib/tools/create/promptOptions.js +0 -88
- package/lib/tools/create/promptOptions.js.map +0 -1
- package/lib/tools/create/updatePackageConfig.d.ts +0 -2
- package/lib/tools/create/updatePackageConfig.js +0 -28
- package/lib/tools/create/updatePackageConfig.js.map +0 -1
- package/lib/tools/create/updateReadme.d.ts +0 -2
- package/lib/tools/create/updateReadme.js +0 -23
- package/lib/tools/create/updateReadme.js.map +0 -1
- package/lib/types/createTypes.d.ts +0 -23
- package/lib/types/createTypes.js +0 -2
- package/lib/types/createTypes.js.map +0 -1
- package/lib/types/types.d.ts +0 -4
- package/lib/types/types.js +0 -2
- package/lib/types/types.js.map +0 -1
- package/lib/update-echo-libs.d.ts +0 -9
- package/lib/update-echo-libs.js +0 -186
- package/lib/update-echo-libs.js.map +0 -1
- package/lib/utils/findConsumerAppPackageJson.d.ts +0 -11
- package/lib/utils/findConsumerAppPackageJson.js +0 -55
- package/lib/utils/findConsumerAppPackageJson.js.map +0 -1
- package/lib/utils/findTopLevelNodeModulesWithCli.d.ts +0 -12
- package/lib/utils/findTopLevelNodeModulesWithCli.js +0 -28
- package/lib/utils/findTopLevelNodeModulesWithCli.js.map +0 -1
- package/lib/utils/getFile.d.ts +0 -34
- package/lib/utils/getFile.js +0 -72
- package/lib/utils/getFile.js.map +0 -1
- package/lib/utils/getFilePath.d.ts +0 -1
- package/lib/utils/getFilePath.js +0 -22
- package/lib/utils/getFilePath.js.map +0 -1
- package/lib/utils/getLatestPkgVersion.d.ts +0 -14
- package/lib/utils/getLatestPkgVersion.js +0 -30
- package/lib/utils/getLatestPkgVersion.js.map +0 -1
- package/lib/utils/logo.d.ts +0 -1
- package/lib/utils/logo.js +0 -12
- package/lib/utils/logo.js.map +0 -1
- package/lib/utils/merge.d.ts +0 -1
- package/lib/utils/merge.js +0 -8
- package/lib/utils/merge.js.map +0 -1
- package/lib/utils/printDevHostVersions.d.ts +0 -18
- package/lib/utils/printDevHostVersions.js +0 -70
- package/lib/utils/printDevHostVersions.js.map +0 -1
- package/lib/utils/printEchoLibsVersions.d.ts +0 -23
- package/lib/utils/printEchoLibsVersions.js +0 -162
- package/lib/utils/printEchoLibsVersions.js.map +0 -1
- package/lib/utils/timer.d.ts +0 -0
- package/lib/utils/timer.js +0 -2
- package/lib/utils/timer.js.map +0 -1
package/lib/update-echo-libs.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Command, Flags } from '@oclif/core';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import fs from 'fs-extra';
|
|
5
|
-
import inquirer from 'inquirer';
|
|
6
|
-
import ora from 'ora';
|
|
7
|
-
import path from 'path';
|
|
8
|
-
import semver from 'semver';
|
|
9
|
-
import { ECHO_HOST_BUILD_OUTPUT_FOLDER, ECHO_HOST_TEMP_BUILD_FOLDER, SUPPORTED_ECHO_LIBS } from './const/common.js';
|
|
10
|
-
import { buildAndCopyDevHost } from './tools/buildScripts/buildAndCopyDevHost.js';
|
|
11
|
-
import { findConsumerAppPackageJson } from './utils/findConsumerAppPackageJson.js';
|
|
12
|
-
import { getLatestPkgVersion } from './utils/getLatestPkgVersion.js';
|
|
13
|
-
import { printEchoLibsVersions } from './utils/printEchoLibsVersions.js';
|
|
14
|
-
export default class UpdateEchoLibs extends Command {
|
|
15
|
-
static description = 'Interactively update echo library dependencies in echo-dev-host and your app';
|
|
16
|
-
static flags = {
|
|
17
|
-
all: Flags.boolean({
|
|
18
|
-
char: 'a',
|
|
19
|
-
description: 'Update all echo libraries to latest without prompting'
|
|
20
|
-
})
|
|
21
|
-
};
|
|
22
|
-
async run() {
|
|
23
|
-
const { flags } = await this.parse(UpdateEchoLibs);
|
|
24
|
-
console.log('Starting update-echo-libs...');
|
|
25
|
-
// 1. Find package.json paths
|
|
26
|
-
const devHostPkgPath = path.resolve(process.cwd(), 'node_modules', '@equinor', 'echo-cli', 'lib', 'echo-dev-host', 'package.json');
|
|
27
|
-
const consumerPkgPath = findConsumerAppPackageJson(process.cwd());
|
|
28
|
-
if (!consumerPkgPath) {
|
|
29
|
-
console.error('Could not find a package.json either in the root folder, or subfolders with @equinor/echo-* dependencies.');
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
// 3. Fetch all echo libs and their latest versions (union of both package.jsons)
|
|
33
|
-
const devHostPkg = fs.readJsonSync(devHostPkgPath);
|
|
34
|
-
const consumerPkg = fs.readJsonSync(consumerPkgPath);
|
|
35
|
-
const getEchoLibs = (pkg) => Object.keys({
|
|
36
|
-
...(pkg.dependencies || {}),
|
|
37
|
-
...(pkg.devDependencies || {}),
|
|
38
|
-
...(pkg.peerDependencies || {})
|
|
39
|
-
}).filter((name) => SUPPORTED_ECHO_LIBS.includes(name));
|
|
40
|
-
const allEchoLibs = Array.from(new Set([...getEchoLibs(devHostPkg), ...getEchoLibs(consumerPkg)]));
|
|
41
|
-
// Fetch latest versions for all echo libs
|
|
42
|
-
const spinner = ora('Fetching latest echo library versions...').start();
|
|
43
|
-
const latestVersions = {};
|
|
44
|
-
for (const lib of allEchoLibs) {
|
|
45
|
-
latestVersions[lib] = await getLatestPkgVersion(lib, spinner);
|
|
46
|
-
}
|
|
47
|
-
spinner.succeed('Fetched latest echo library versions.');
|
|
48
|
-
// 2. Print current echo lib versions
|
|
49
|
-
await printEchoLibsVersions({
|
|
50
|
-
devHostPkgPath,
|
|
51
|
-
appPkgPath: consumerPkgPath,
|
|
52
|
-
echoLibVersionsToUse: latestVersions,
|
|
53
|
-
hideNewVersionsWarningMessage: true
|
|
54
|
-
});
|
|
55
|
-
// 4. Ask user about auto/manual update
|
|
56
|
-
let autoBump = flags.all;
|
|
57
|
-
if (!flags.all) {
|
|
58
|
-
const answer = await inquirer.prompt([
|
|
59
|
-
{
|
|
60
|
-
type: 'confirm',
|
|
61
|
-
name: 'autoBump',
|
|
62
|
-
message: `Automatically update all outdated echo libraries to their latest versions?`,
|
|
63
|
-
default: true
|
|
64
|
-
}
|
|
65
|
-
]);
|
|
66
|
-
autoBump = answer.autoBump;
|
|
67
|
-
}
|
|
68
|
-
// 5. Update both dev host and consumer app package.jsons
|
|
69
|
-
const isDevHostUpdated = await updateEchoLibsInPackageJson({
|
|
70
|
-
pkgPath: devHostPkgPath,
|
|
71
|
-
pkgLabel: 'echo-dev-host',
|
|
72
|
-
latestVersions,
|
|
73
|
-
autoBump
|
|
74
|
-
});
|
|
75
|
-
const isConsumerUpdated = await updateEchoLibsInPackageJson({
|
|
76
|
-
pkgPath: consumerPkgPath,
|
|
77
|
-
pkgLabel: 'consumer app',
|
|
78
|
-
latestVersions,
|
|
79
|
-
autoBump
|
|
80
|
-
});
|
|
81
|
-
console.log(chalk.green('\nUpdated all echo libraries in echo-dev-host and your app, where needed.'));
|
|
82
|
-
console.log(chalk.green('\nSee the updated echo lib versions in the table below.'));
|
|
83
|
-
// 6. Print echo lib versions after update
|
|
84
|
-
await printEchoLibsVersions({
|
|
85
|
-
devHostPkgPath,
|
|
86
|
-
appPkgPath: consumerPkgPath,
|
|
87
|
-
echoLibVersionsToUse: latestVersions,
|
|
88
|
-
hideNewVersionsWarningMessage: true
|
|
89
|
-
});
|
|
90
|
-
// Rebuild dev host if needed
|
|
91
|
-
if (isDevHostUpdated) {
|
|
92
|
-
console.log(`\nDependencies updated. Rebuilding echo-dev-host...\n`);
|
|
93
|
-
const cliNodeModules = path.resolve(process.cwd(), 'node_modules', '@equinor', 'echo-cli');
|
|
94
|
-
const finalOutput = path.join(cliNodeModules, ECHO_HOST_BUILD_OUTPUT_FOLDER);
|
|
95
|
-
await buildAndCopyDevHost({
|
|
96
|
-
cliNodeModules,
|
|
97
|
-
tmpDevHostFolder: path.resolve(process.cwd(), ECHO_HOST_TEMP_BUILD_FOLDER),
|
|
98
|
-
finalOutputDir: finalOutput
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
if (isConsumerUpdated) {
|
|
102
|
-
console.log(chalk.hex('#FFA500')(`\n⚠️ Don't forget to run npm install in your consumer app!`));
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
async function updateEchoLibsInPackageJson({ pkgPath, pkgLabel, latestVersions, autoBump }) {
|
|
107
|
-
let pkg;
|
|
108
|
-
try {
|
|
109
|
-
pkg = fs.readJsonSync(pkgPath);
|
|
110
|
-
console.log(chalk.cyan(`\nUpdating echo libs in ${pkgLabel} \n Using: ${chalk.yellow(pkgPath)}`));
|
|
111
|
-
}
|
|
112
|
-
catch (error) {
|
|
113
|
-
console.error(`Could not read package.json at ${chalk.yellow(pkgPath)}.`);
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
const sections = [
|
|
117
|
-
'dependencies',
|
|
118
|
-
'devDependencies',
|
|
119
|
-
'peerDependencies'
|
|
120
|
-
];
|
|
121
|
-
let updated = false;
|
|
122
|
-
const changes = {};
|
|
123
|
-
console.log(chalk.cyanBright('Please provide a valid semver version number for each echo library.\n The latest version is shown in brackets [] and provided as a default value.\n'));
|
|
124
|
-
for (const section of sections) {
|
|
125
|
-
const deps = pkg[section] || {};
|
|
126
|
-
for (const lib of Object.keys(deps).filter((n) => SUPPORTED_ECHO_LIBS.includes(n))) {
|
|
127
|
-
const current = deps[lib];
|
|
128
|
-
const latest = latestVersions[lib];
|
|
129
|
-
if (!latest || current === latest)
|
|
130
|
-
continue;
|
|
131
|
-
let newVersion = latest;
|
|
132
|
-
if (!autoBump) {
|
|
133
|
-
let valid = false;
|
|
134
|
-
while (!valid) {
|
|
135
|
-
const answer = await inquirer.prompt([
|
|
136
|
-
{
|
|
137
|
-
type: 'input',
|
|
138
|
-
name: 'version',
|
|
139
|
-
message: `${lib} (${section}): current ${current}, latest ${latest} [${latest}]:`,
|
|
140
|
-
default: latest
|
|
141
|
-
}
|
|
142
|
-
]);
|
|
143
|
-
newVersion = answer.version || latest;
|
|
144
|
-
if (semver.valid(newVersion)) {
|
|
145
|
-
valid = true;
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
console.log(chalk.red('Please provide a valid semver version number.'));
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
if (newVersion !== current) {
|
|
153
|
-
deps[lib] = newVersion;
|
|
154
|
-
updated = true;
|
|
155
|
-
if (!changes[section])
|
|
156
|
-
changes[section] = [];
|
|
157
|
-
changes[section].push(`${lib} to ${newVersion}`);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
if (updated) {
|
|
161
|
-
pkg[section] = deps;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
if (updated) {
|
|
165
|
-
fs.writeJsonSync(pkgPath, pkg, { spaces: 4 });
|
|
166
|
-
logGroupedEchoLibUpdates(changes, console.log);
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
console.log(chalk.gray(`\nNo echo library versions needed updating in ${pkgLabel} package.json.\n`));
|
|
170
|
-
}
|
|
171
|
-
return updated;
|
|
172
|
-
}
|
|
173
|
-
function logGroupedEchoLibUpdates(changes, logFn) {
|
|
174
|
-
logFn(chalk.green('\nSummary of updated echo libs: \n'));
|
|
175
|
-
['dependencies', 'devDependencies', 'peerDependencies'].forEach((section) => {
|
|
176
|
-
if (changes[section] && changes[section].length > 0) {
|
|
177
|
-
logFn(chalk.cyan(section));
|
|
178
|
-
changes[section].forEach((msg) => {
|
|
179
|
-
logFn(` - ${msg}`);
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
logFn('');
|
|
184
|
-
}
|
|
185
|
-
UpdateEchoLibs.run();
|
|
186
|
-
//# sourceMappingURL=update-echo-libs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-echo-libs.js","sourceRoot":"","sources":["../src/update-echo-libs.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,6BAA6B,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACpH,OAAO,EAAE,mBAAmB,EAAE,MA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,OAAO,CAAC,GAAG,CAAC,CAAC;IACnD,CAAC;SAAM,CAAC;QACJ,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,iDAAiD,QAAQ,kBAAkB,CAAC,CAAC,CAAC;IACzG,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,SAAS,wBAAwB,CAAC,OAAiC,EAAE,KAA4B;IAC7F,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC,CAAC;IACxD,CAAC,cAAc,EAAE,iBAAiB,EAAE,kBAAkB,CAAW,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QACnF,IAAI,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClD,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YAC3B,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC7B,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC;YACzB,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED,cAAc,CAAC,GAAG,EAAE,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare function findConsumerAppPackageJson(startDir: string): string | undefined;
|
|
2
|
-
/**
|
|
3
|
-
* Extracts the dependencies from a package.json object that are included in the `SUPPORTED_ECHO_LIBS` list.
|
|
4
|
-
*
|
|
5
|
-
* Merges `dependencies`, `peerDependencies`, and `devDependencies` from the provided package object,
|
|
6
|
-
* then filters and returns only those whose names are present in `SUPPORTED_ECHO_LIBS`.
|
|
7
|
-
*
|
|
8
|
-
* @param pkg - The package.json object to extract dependencies from.
|
|
9
|
-
* @returns An array of tuples, where each tuple contains the dependency name and its version as strings.
|
|
10
|
-
*/
|
|
11
|
-
export declare const getEchoDeps: (pkg: any) => [string, string][];
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { SUPPORTED_ECHO_LIBS } from '../const/common.js';
|
|
4
|
-
export function findConsumerAppPackageJson(startDir) {
|
|
5
|
-
const tried = [];
|
|
6
|
-
// 1. Check CWD
|
|
7
|
-
const rootPkg = path.join(startDir, 'package.json');
|
|
8
|
-
if (fs.existsSync(rootPkg)) {
|
|
9
|
-
const pkg = fs.readJsonSync(rootPkg);
|
|
10
|
-
if (hasEchoLibs(pkg))
|
|
11
|
-
return rootPkg;
|
|
12
|
-
tried.push(rootPkg);
|
|
13
|
-
}
|
|
14
|
-
// 2. Check immediate subfolders (monorepo style)
|
|
15
|
-
const subfolders = fs
|
|
16
|
-
.readdirSync(startDir)
|
|
17
|
-
.filter((f) => fs.statSync(path.join(startDir, f)).isDirectory())
|
|
18
|
-
.filter((f) => !['node_modules', 'dist', 'build', '.git'].includes(f));
|
|
19
|
-
for (const folder of subfolders) {
|
|
20
|
-
const pkgPath = path.join(startDir, folder, 'package.json');
|
|
21
|
-
if (fs.existsSync(pkgPath)) {
|
|
22
|
-
const pkg = fs.readJsonSync(pkgPath);
|
|
23
|
-
if (hasEchoLibs(pkg))
|
|
24
|
-
return pkgPath;
|
|
25
|
-
tried.push(pkgPath);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
// 3. Not found
|
|
29
|
-
// Optionally: log where we looked
|
|
30
|
-
// console.log('Checked for echo app package.json in:', tried);
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
function hasEchoLibs(pkg) {
|
|
34
|
-
return getEchoDeps(pkg).length > 0;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Extracts the dependencies from a package.json object that are included in the `SUPPORTED_ECHO_LIBS` list.
|
|
38
|
-
*
|
|
39
|
-
* Merges `dependencies`, `peerDependencies`, and `devDependencies` from the provided package object,
|
|
40
|
-
* then filters and returns only those whose names are present in `SUPPORTED_ECHO_LIBS`.
|
|
41
|
-
*
|
|
42
|
-
* @param pkg - The package.json object to extract dependencies from.
|
|
43
|
-
* @returns An array of tuples, where each tuple contains the dependency name and its version as strings.
|
|
44
|
-
*/
|
|
45
|
-
export const getEchoDeps = (pkg) => {
|
|
46
|
-
const merged = {
|
|
47
|
-
...(pkg.dependencies || {}),
|
|
48
|
-
...(pkg.peerDependencies || {}),
|
|
49
|
-
...(pkg.devDependencies || {})
|
|
50
|
-
};
|
|
51
|
-
return Object.entries(merged)
|
|
52
|
-
.filter(([name]) => SUPPORTED_ECHO_LIBS.includes(name))
|
|
53
|
-
.map(([name, version]) => [name, String(version)]);
|
|
54
|
-
};
|
|
55
|
-
//# sourceMappingURL=findConsumerAppPackageJson.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"findConsumerAppPackageJson.js","sourceRoot":"","sources":["../../src/utils/findConsumerAppPackageJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,UAAU,0BAA0B,CAAC,QAAgB;IACvD,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,eAAe;IACf,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;IACpD,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,WAAW,CAAC,GAAG,CAAC;YAAE,OAAO,OAAO,CAAC;QACrC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC;IACD,iDAAiD;IACjD,MAAM,UAAU,GAAG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C,OAAO,CAAC,MAAM,CAAC;SACxB,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SACtD,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,CAAqB,CAAC,CAAC;AAC/E,CAAC,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Searches upwards from the specified starting directory to find the topmost
|
|
3
|
-
* `@equinor/echo-cli` package inside a `node_modules` folder.
|
|
4
|
-
*
|
|
5
|
-
* Needed to support nested folder structures, where the `echo-cli` is located in the top-level `node_modules`,
|
|
6
|
-
* while the app running this code is in a subfolder. (For example, in a monorepo setup, like echo 3d)
|
|
7
|
-
*
|
|
8
|
-
* @param startDir - The directory from which to start searching.
|
|
9
|
-
* @returns The absolute path to the topmost `node_modules` directory found,
|
|
10
|
-
* or `undefined` if not found.
|
|
11
|
-
*/
|
|
12
|
-
export declare function findTopNodeModulesWithEchoCli(startDir: string): string | undefined;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
/**
|
|
4
|
-
* Searches upwards from the specified starting directory to find the topmost
|
|
5
|
-
* `@equinor/echo-cli` package inside a `node_modules` folder.
|
|
6
|
-
*
|
|
7
|
-
* Needed to support nested folder structures, where the `echo-cli` is located in the top-level `node_modules`,
|
|
8
|
-
* while the app running this code is in a subfolder. (For example, in a monorepo setup, like echo 3d)
|
|
9
|
-
*
|
|
10
|
-
* @param startDir - The directory from which to start searching.
|
|
11
|
-
* @returns The absolute path to the topmost `node_modules` directory found,
|
|
12
|
-
* or `undefined` if not found.
|
|
13
|
-
*/
|
|
14
|
-
export function findTopNodeModulesWithEchoCli(startDir) {
|
|
15
|
-
let dir = path.resolve(startDir);
|
|
16
|
-
let lastDir = null;
|
|
17
|
-
let topmost = undefined;
|
|
18
|
-
while (dir !== lastDir) {
|
|
19
|
-
const candidate = path.join(dir, 'node_modules', '@equinor', 'echo-cli');
|
|
20
|
-
if (fs.existsSync(candidate)) {
|
|
21
|
-
topmost = path.join(dir, 'node_modules');
|
|
22
|
-
}
|
|
23
|
-
lastDir = dir;
|
|
24
|
-
dir = path.dirname(dir);
|
|
25
|
-
}
|
|
26
|
-
return topmost;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=findTopLevelNodeModulesWithCli.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"findTopLevelNodeModulesWithCli.js","sourceRoot":"","sources":["../../src/utils/findTopLevelNodeModulesWithCli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;;;;;;GAUG;AACH,MAAM,UAAU,6BAA6B,CAAC,QAAgB;IAC1D,IAAI,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjC,IAAI,OAAO,GAAkB,IAAI,CAAC;IAClC,IAAI,OAAO,GAAuB,SAAS,CAAC;IAC5C,OAAO,GAAG,KAAK,OAAO,EAAE,CAAC;QACrB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;QACzE,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3B,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,GAAG,GAAG,CAAC;QACd,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
package/lib/utils/getFile.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Configuration } from 'webpack';
|
|
2
|
-
/**
|
|
3
|
-
* Asynchronously checks if a file exists and is readable in the specified directory.
|
|
4
|
-
*
|
|
5
|
-
* @param currentDir - The directory in which to look for the file.
|
|
6
|
-
* @param fileName - The name of the file to check for.
|
|
7
|
-
* @returns A promise that resolves to the full path of the file if it is accessible.
|
|
8
|
-
* @throws Exits the process with code 1 and logs an error if the file is not accessible.
|
|
9
|
-
*/
|
|
10
|
-
export default function getFilePath(currentDir: string, fileName: string): Promise<string>;
|
|
11
|
-
/**
|
|
12
|
-
* Reads and parses a JSON file from the specified path, returning its contents as a typed object.
|
|
13
|
-
*
|
|
14
|
-
* @template T - The expected type of the parsed JSON object.
|
|
15
|
-
* @param currentDir - The current working directory to resolve the file path from.
|
|
16
|
-
* @param filePath - The relative or absolute path to the JSON file.
|
|
17
|
-
* @returns A promise that resolves to the parsed JSON object of type T.
|
|
18
|
-
* @throws Will log an error and return undefined if the file cannot be read or parsed.
|
|
19
|
-
*/
|
|
20
|
-
export declare function readJSONFile<T>(currentDir: string, filePath: string): Promise<T>;
|
|
21
|
-
/**
|
|
22
|
-
* Asynchronously loads a Webpack configuration file from a specified path.
|
|
23
|
-
*
|
|
24
|
-
* This function resolves the absolute file path using `getFilePath`, converts it to a file URL,
|
|
25
|
-
* and dynamically imports the configuration module. It supports both ESM and CommonJS module formats,
|
|
26
|
-
* returning the configuration object accordingly.
|
|
27
|
-
*
|
|
28
|
-
* @param currentDir - The current working directory to resolve relative paths.
|
|
29
|
-
* @param filePath - The relative or absolute path to the Webpack configuration file.
|
|
30
|
-
* @returns A promise that resolves to the loaded Webpack `Configuration` object.
|
|
31
|
-
*
|
|
32
|
-
* @throws Will throw an error if the file cannot be found or imported.
|
|
33
|
-
*/
|
|
34
|
-
export declare function getWebpackConfigFile(currentDir: string, filePath: string): Promise<Configuration>;
|
package/lib/utils/getFile.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { promisify } from 'util';
|
|
5
|
-
const access = promisify(fs.access);
|
|
6
|
-
/**
|
|
7
|
-
* Asynchronously checks if a file exists and is readable in the specified directory.
|
|
8
|
-
*
|
|
9
|
-
* @param currentDir - The directory in which to look for the file.
|
|
10
|
-
* @param fileName - The name of the file to check for.
|
|
11
|
-
* @returns A promise that resolves to the full path of the file if it is accessible.
|
|
12
|
-
* @throws Exits the process with code 1 and logs an error if the file is not accessible.
|
|
13
|
-
*/
|
|
14
|
-
export default async function getFilePath(currentDir, fileName) {
|
|
15
|
-
const currentPath = path.join(currentDir, `${fileName}`);
|
|
16
|
-
try {
|
|
17
|
-
await access(currentPath, fs.constants.R_OK);
|
|
18
|
-
return currentPath;
|
|
19
|
-
}
|
|
20
|
-
catch (err) {
|
|
21
|
-
if (err instanceof Error) {
|
|
22
|
-
console.error(`%s Cant access ${fileName}`, chalk.red.bold('ERROR'));
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
throw err;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Reads and parses a JSON file from the specified path, returning its contents as a typed object.
|
|
32
|
-
*
|
|
33
|
-
* @template T - The expected type of the parsed JSON object.
|
|
34
|
-
* @param currentDir - The current working directory to resolve the file path from.
|
|
35
|
-
* @param filePath - The relative or absolute path to the JSON file.
|
|
36
|
-
* @returns A promise that resolves to the parsed JSON object of type T.
|
|
37
|
-
* @throws Will log an error and return undefined if the file cannot be read or parsed.
|
|
38
|
-
*/
|
|
39
|
-
export async function readJSONFile(currentDir, filePath) {
|
|
40
|
-
const path = await getFilePath(currentDir, filePath);
|
|
41
|
-
let parsedFile;
|
|
42
|
-
try {
|
|
43
|
-
parsedFile = JSON.parse(fs.readFileSync(path).toString());
|
|
44
|
-
// ...use json...
|
|
45
|
-
}
|
|
46
|
-
catch (e) {
|
|
47
|
-
console.error('Failed to parse JSON:', e);
|
|
48
|
-
}
|
|
49
|
-
return parsedFile;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Asynchronously loads a Webpack configuration file from a specified path.
|
|
53
|
-
*
|
|
54
|
-
* This function resolves the absolute file path using `getFilePath`, converts it to a file URL,
|
|
55
|
-
* and dynamically imports the configuration module. It supports both ESM and CommonJS module formats,
|
|
56
|
-
* returning the configuration object accordingly.
|
|
57
|
-
*
|
|
58
|
-
* @param currentDir - The current working directory to resolve relative paths.
|
|
59
|
-
* @param filePath - The relative or absolute path to the Webpack configuration file.
|
|
60
|
-
* @returns A promise that resolves to the loaded Webpack `Configuration` object.
|
|
61
|
-
*
|
|
62
|
-
* @throws Will throw an error if the file cannot be found or imported.
|
|
63
|
-
*/
|
|
64
|
-
export async function getWebpackConfigFile(currentDir, filePath) {
|
|
65
|
-
const path = await getFilePath(currentDir, filePath);
|
|
66
|
-
// Convert the path to a file URL
|
|
67
|
-
const fileUrl = new URL(`file://${path}`);
|
|
68
|
-
const config = await import(fileUrl.href);
|
|
69
|
-
// Return the configuration, handling both ESM and CommonJS formats
|
|
70
|
-
return (config.default || config);
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=getFile.js.map
|
package/lib/utils/getFile.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getFile.js","sourceRoot":"","sources":["../../src/utils/getFile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAGjC,MAAM,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,WAAW,CAAC,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AG,IAAI,GAAG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;IAE1C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1C,mEAAmE;IACnE,OAAO,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAkB,CAAC;AACvD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function getFilePath(currentDir: string, fileName: string): Promise<string>;
|
package/lib/utils/getFilePath.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import * as fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { promisify } from 'util';
|
|
5
|
-
const access = promisify(fs.access);
|
|
6
|
-
export default async function getFilePath(currentDir, fileName) {
|
|
7
|
-
const currentPath = path.join(currentDir, `${fileName}`);
|
|
8
|
-
try {
|
|
9
|
-
await access(currentPath, fs.constants.R_OK);
|
|
10
|
-
return currentPath;
|
|
11
|
-
}
|
|
12
|
-
catch (err) {
|
|
13
|
-
if (err instanceof Error) {
|
|
14
|
-
console.error(`%s Cant access ${fileName}`, chalk.red.bold('ERROR'));
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
throw err;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=getFilePath.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getFilePath.js","sourceRoot":"","sources":["../../src/utils/getFilePath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC,MAAM,MAAM,GAAG,SAAS,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;AAEpC,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,WAAW,CAAC,UAAkB,EAAE,QAAgB;IAC1E,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,QAAQ,EAAE,CAAC,CAAC;IAEzD,IAAI,CAAC;QACD,MAAM,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,WAAW,CAAC;IACvB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACX,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;YACvB,OAAO,CAAC,KAAK,CAAC,kBAAkB,QAAQ,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;aAAM,CAAC;YACJ,MAAM,GAAG,CAAC;QACd,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Ora } from 'ora';
|
|
3
|
-
/**
|
|
4
|
-
* Retrieves the latest published version of an npm package.
|
|
5
|
-
*
|
|
6
|
-
* @param pkg - The name of the npm package to query.
|
|
7
|
-
* @param spinner - An Ora spinner instance used to display progress and status messages.
|
|
8
|
-
* @returns A promise that resolves to the latest version string of the package, or an empty string if not found or on error.
|
|
9
|
-
*
|
|
10
|
-
* @remarks
|
|
11
|
-
* This function uses the `npm view <pkg> version` command to fetch the latest version.
|
|
12
|
-
* The spinner is updated to reflect the progress, warnings, or failures during the process.
|
|
13
|
-
*/
|
|
14
|
-
export declare function getLatestPkgVersion(pkg: string, spinner: Ora): Promise<string>;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { execSync } from 'child_process';
|
|
3
|
-
/**
|
|
4
|
-
* Retrieves the latest published version of an npm package.
|
|
5
|
-
*
|
|
6
|
-
* @param pkg - The name of the npm package to query.
|
|
7
|
-
* @param spinner - An Ora spinner instance used to display progress and status messages.
|
|
8
|
-
* @returns A promise that resolves to the latest version string of the package, or an empty string if not found or on error.
|
|
9
|
-
*
|
|
10
|
-
* @remarks
|
|
11
|
-
* This function uses the `npm view <pkg> version` command to fetch the latest version.
|
|
12
|
-
* The spinner is updated to reflect the progress, warnings, or failures during the process.
|
|
13
|
-
*/
|
|
14
|
-
export async function getLatestPkgVersion(pkg, spinner) {
|
|
15
|
-
try {
|
|
16
|
-
spinner.text = `Fetching latest version for ${pkg}...`;
|
|
17
|
-
const result = execSync(`npm view ${pkg} version`, { stdio: ['pipe', 'pipe', 'ignore'] })
|
|
18
|
-
.toString()
|
|
19
|
-
.trim();
|
|
20
|
-
if (!result) {
|
|
21
|
-
spinner.warn(`No version found for ${pkg}.`);
|
|
22
|
-
}
|
|
23
|
-
return result;
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
spinner.fail(`Could not fetch latest version for ${pkg}.`);
|
|
27
|
-
return '';
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=getLatestPkgVersion.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLatestPkgVersion.js","sourceRoot":"","sources":["../../src/utils/getLatestPkgVersion.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,GAAW,EAAE,OAAY;IAC/D,IAAI,CAAC;QACD,OAAO,CAAC,IAAI,GAAG,+BAA+B,GAAG,KAAK,CAAC;QACvD,MAAM,MAAM,GAAG,QAAQ,CAAC,YAAY,GAAG,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC;aACpF,QAAQ,EAAE;aACV,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,OAAO,CAAC,IAAI,CAAC,wBAAwB,GAAG,GAAG,CAAC,CAAC;QACjD,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,sCAAsC,GAAG,GAAG,CAAC,CAAC;QAC3D,OAAO,EAAE,CAAC;IACd,CAAC;AACL,CAAC"}
|
package/lib/utils/logo.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function echoCliLogo(): void;
|
package/lib/utils/logo.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import figlet from 'figlet';
|
|
3
|
-
export function echoCliLogo() {
|
|
4
|
-
console.log(`${chalk.cyan.bold('echo-cli')} - by Echo Core Team`);
|
|
5
|
-
console.log('Tool for building and running of Echo applications.\n');
|
|
6
|
-
console.log(figlet.textSync('Echo', {
|
|
7
|
-
font: '3D-ASCII',
|
|
8
|
-
horizontalLayout: 'default',
|
|
9
|
-
verticalLayout: 'default'
|
|
10
|
-
}));
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=logo.js.map
|
package/lib/utils/logo.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logo.js","sourceRoot":"","sources":["../../src/utils/logo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,UAAU,WAAW;IACvB,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC;IAClE,OAAO,CAAC,GAAG,CAAC,uDAAuD,CAAC,CAAC;IACrE,OAAO,CAAC,GAAG,CACP,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;QACpB,IAAI,EAAE,UAAU;QAChB,gBAAgB,EAAE,SAAS;QAC3B,cAAc,EAAE,SAAS;KAC5B,CAAC,CACL,CAAC;AACN,CAAC"}
|
package/lib/utils/merge.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function merge<T>(...args: T[][]): T[];
|
package/lib/utils/merge.js
DELETED
package/lib/utils/merge.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/utils/merge.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK,CAAI,GAAG,IAAW;IACnC,IAAI,GAAG,GAAQ,EAAE,CAAC;IAClB,IAAI,CAAC,OAAO,CAAC,CAAC,IAAS,EAAE,EAAE;QACvB,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACf,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Prints the versions of all `@equinor/echo-` libraries listed as dependencies in a given package.json file.
|
|
3
|
-
* Optionally, fetches and displays the latest available versions from the npm registry for comparison.
|
|
4
|
-
*
|
|
5
|
-
* @param args - An object containing:
|
|
6
|
-
* - `devHostPkgPath`: The file path to the package.json to inspect.
|
|
7
|
-
* - `fetchLatest` (optional): If true, fetches the latest versions from npm and compares them to the installed versions.
|
|
8
|
-
* @returns A promise that resolves when the operation is complete.
|
|
9
|
-
*
|
|
10
|
-
* @remarks
|
|
11
|
-
* - Outputs version information to the console, using colored formatting for clarity.
|
|
12
|
-
* - If `fetchLatest` is true, displays whether each dependency is up to date or shows the latest version available.
|
|
13
|
-
* - Handles missing files and invalid JSON gracefully, printing error messages to the console.
|
|
14
|
-
*/
|
|
15
|
-
export declare function printDevHostVersions(args: {
|
|
16
|
-
devHostPkgPath: string;
|
|
17
|
-
fetchLatest?: boolean;
|
|
18
|
-
}): Promise<void>;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
|
-
import ora from 'ora';
|
|
4
|
-
import { getLatestPkgVersion } from './getLatestPkgVersion.js';
|
|
5
|
-
/**
|
|
6
|
-
* Prints the versions of all `@equinor/echo-` libraries listed as dependencies in a given package.json file.
|
|
7
|
-
* Optionally, fetches and displays the latest available versions from the npm registry for comparison.
|
|
8
|
-
*
|
|
9
|
-
* @param args - An object containing:
|
|
10
|
-
* - `devHostPkgPath`: The file path to the package.json to inspect.
|
|
11
|
-
* - `fetchLatest` (optional): If true, fetches the latest versions from npm and compares them to the installed versions.
|
|
12
|
-
* @returns A promise that resolves when the operation is complete.
|
|
13
|
-
*
|
|
14
|
-
* @remarks
|
|
15
|
-
* - Outputs version information to the console, using colored formatting for clarity.
|
|
16
|
-
* - If `fetchLatest` is true, displays whether each dependency is up to date or shows the latest version available.
|
|
17
|
-
* - Handles missing files and invalid JSON gracefully, printing error messages to the console.
|
|
18
|
-
*/
|
|
19
|
-
export async function printDevHostVersions(args) {
|
|
20
|
-
const { devHostPkgPath, fetchLatest } = args;
|
|
21
|
-
if (fs.existsSync(devHostPkgPath)) {
|
|
22
|
-
try {
|
|
23
|
-
const pkg = fs.readJsonSync(devHostPkgPath);
|
|
24
|
-
const echoLibs = Object.entries(pkg.dependencies || {}).filter(([name]) => name.startsWith('@equinor/echo-'));
|
|
25
|
-
if (echoLibs.length > 0) {
|
|
26
|
-
let spinner;
|
|
27
|
-
if (fetchLatest) {
|
|
28
|
-
spinner = ora();
|
|
29
|
-
console.log(chalk.yellow(`Fetching latest versions for echo libraries...`));
|
|
30
|
-
}
|
|
31
|
-
let hasOutdatedLibs = false;
|
|
32
|
-
for (const [name, version] of echoLibs) {
|
|
33
|
-
if (fetchLatest) {
|
|
34
|
-
const latest = await getLatestPkgVersion(name, spinner);
|
|
35
|
-
let statusText;
|
|
36
|
-
if (!latest) {
|
|
37
|
-
statusText = chalk.gray('(could not fetch latest)');
|
|
38
|
-
}
|
|
39
|
-
else if (version === latest) {
|
|
40
|
-
statusText = chalk.green('(up to date)');
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
statusText = chalk.red(`(latest: ${latest})`); // orange
|
|
44
|
-
hasOutdatedLibs = true;
|
|
45
|
-
}
|
|
46
|
-
console.log(chalk.yellow(`${name}: ${version} `) + statusText);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
console.log(chalk.yellow(`${name}: ${version}`));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (spinner)
|
|
53
|
-
spinner.stop();
|
|
54
|
-
if (hasOutdatedLibs) {
|
|
55
|
-
console.log(chalk.hex('#FFA500')('Updates available for echo libraries. Run npx update-echo-dev-host-deps to upgrade.'));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
console.log(chalk.gray(`No @equinor/echo- libraries found in ${devHostPkgPath}.`));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
catch (err) {
|
|
63
|
-
console.log(chalk.red(`Could not read ${devHostPkgPath}. Is it valid JSON?`));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
console.log(chalk.red(`Could not read echo lib version numbers: ${devHostPkgPath} does not exist.`));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=printDevHostVersions.js.map
|