From 4760866c7782b2651c1c319ae1a757f0ab21f1b3 Mon Sep 17 00:00:00 2001 From: Otavio Jacobi Date: Thu, 22 Aug 2024 13:03:37 -0300 Subject: [PATCH] Update all references of lib to src Change-type: patch --- CONTRIBUTING.md | 8 ++++---- INSTALL-ADVANCED.md | 2 +- INSTALL-MAC.md | 2 +- automation/build-bin.ts | 2 +- automation/capitanodoc/capitanodoc.ts | 2 +- automation/capitanodoc/index.ts | 2 +- automation/capitanodoc/markdown.ts | 4 ++-- automation/check-doc.ts | 4 ++-- bin/dev.js | 10 +++++----- package.json | 6 +++--- src/events.ts | 2 +- src/fast-boot.ts | 4 ++-- src/utils/bootstrap.ts | 4 ++-- tests/utils/device/live.spec.ts | 8 ++++---- tsconfig.dev.json | 2 +- tsconfig.json | 2 +- 16 files changed, 32 insertions(+), 32 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c310c863..0cf0af36 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -115,9 +115,9 @@ The content sources for the auto generation of `docs/balena-cli.md` are: * [Selected sections](https://github.com/balena-io/balena-cli/blob/v12.23.0/automation/capitanodoc/capitanodoc.ts#L199-L204) of the README file. -* The CLI's command documentation in source code (`lib/commands/` folder), for example: - * `lib/commands/push.ts` - * `lib/commands/env/add.ts` +* The CLI's command documentation in source code (`src/commands/` folder), for example: + * `src/commands/push.ts` + * `src/commands/env/add.ts` The README file is manually edited, but subsections are automatically extracted for inclusion in `docs/balena-cli.md` by the `getCapitanoDoc()` function in @@ -224,7 +224,7 @@ command, or by manually editing or copying files to the `node_modules` folder. Unexpected behavior may then be observed because of the CLI's use of the [fast-boot2](https://www.npmjs.com/package/fast-boot2) package that caches module resolution. -`fast-boot2` is configured in `lib/fast-boot.ts` to automatically invalidate the cache if +`fast-boot2` is configured in `src/fast-boot.ts` to automatically invalidate the cache if changes are made to the `package.json` or `npm-shrinkwrap.json` files, but the cache won't be automatically invalidated if `npm link` is used or if manual modifications are made to the `node_modules` folder. In this situation: diff --git a/INSTALL-ADVANCED.md b/INSTALL-ADVANCED.md index 25672d4c..c828e37b 100644 --- a/INSTALL-ADVANCED.md +++ b/INSTALL-ADVANCED.md @@ -40,7 +40,7 @@ By default, the CLI is installed to the following folders: OS | Folders --- | --- Windows: | `C:\Program Files\balena-cli\` -macOS: | `/usr/local/lib/balena-cli/`
`/usr/local/bin/balena` +macOS: | `/usr/local/src/balena-cli/`
`/usr/local/bin/balena` ## Standalone Zip Package diff --git a/INSTALL-MAC.md b/INSTALL-MAC.md index 7cfa543d..0b14f542 100644 --- a/INSTALL-MAC.md +++ b/INSTALL-MAC.md @@ -27,7 +27,7 @@ To update the balena CLI, repeat the steps above for the new version. To uninstall it, run the following command on a terminal prompt: ```text -sudo /usr/local/lib/balena-cli/bin/uninstall +sudo /usr/local/src/balena-cli/bin/uninstall ``` ## Additional Dependencies diff --git a/automation/build-bin.ts b/automation/build-bin.ts index 520f5f39..2ba3c479 100644 --- a/automation/build-bin.ts +++ b/automation/build-bin.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import type { JsonVersions } from '../lib/commands/version/index'; +import type { JsonVersions } from '../src/commands/version/index'; import { run as oclifRun } from '@oclif/core'; import * as archiver from 'archiver'; diff --git a/automation/capitanodoc/capitanodoc.ts b/automation/capitanodoc/capitanodoc.ts index 93a7f5b3..f687050d 100644 --- a/automation/capitanodoc/capitanodoc.ts +++ b/automation/capitanodoc/capitanodoc.ts @@ -28,7 +28,7 @@ import { GlobSync } from 'glob'; * * IMPORTANT * - * All commands need to be stored under a folder in lib/commands to maintain uniformity + * All commands need to be stored under a folder in src/commands to maintain uniformity * Generating docs will error out if directive not followed * To add a custom heading for command docs, add the heading next to the folder name * in the `commandHeadings` dictionary. diff --git a/automation/capitanodoc/index.ts b/automation/capitanodoc/index.ts index 75e79272..b82f0097 100644 --- a/automation/capitanodoc/index.ts +++ b/automation/capitanodoc/index.ts @@ -18,7 +18,7 @@ import * as path from 'path'; import { getCapitanoDoc } from './capitanodoc'; import type { Category, Document, OclifCommand } from './doc-types'; import * as markdown from './markdown'; -import { stripIndent } from '../../lib/utils/lazy'; +import { stripIndent } from '../../src/utils/lazy'; /** * Generates the markdown document (as a string) for the CLI documentation diff --git a/automation/capitanodoc/markdown.ts b/automation/capitanodoc/markdown.ts index c0e2dc80..44cfc422 100644 --- a/automation/capitanodoc/markdown.ts +++ b/automation/capitanodoc/markdown.ts @@ -18,8 +18,8 @@ import { Parser } from '@oclif/core'; import * as ent from 'ent'; import * as _ from 'lodash'; -import { getManualSortCompareFunction } from '../../lib/utils/helpers'; -import { capitanoizeOclifUsage } from '../../lib/utils/oclif-utils'; +import { getManualSortCompareFunction } from '../../src/utils/helpers'; +import { capitanoizeOclifUsage } from '../../src/utils/oclif-utils'; import type { Category, Document, OclifCommand } from './doc-types'; function renderOclifCommand(command: OclifCommand): string[] { diff --git a/automation/check-doc.ts b/automation/check-doc.ts index 9ad65dc4..bdc33a49 100644 --- a/automation/check-doc.ts +++ b/automation/check-doc.ts @@ -43,8 +43,8 @@ async function checkBuildTimestamps() { ...gitStatus.staged, ...gitStatus.renamed.map((o) => o.to), ]) - // select only staged files that start with lib/ or typings/ - .filter((f) => f.match(/^(lib|typings)[/\\]/)) + // select only staged files that start with src/ or typings/ + .filter((f) => f.match(/^(src|typings)[/\\]/)) .map((f) => path.join(ROOT, f)); const fStats = await Promise.all(stagedFiles.map((f) => fs.stat(f))); diff --git a/bin/dev.js b/bin/dev.js index ceaf47c4..0d1662ea 100755 --- a/bin/dev.js +++ b/bin/dev.js @@ -29,7 +29,7 @@ const path = require('path'); const rootDir = path.join(__dirname, '..'); // Allow balena-dev to work with oclif by temporarily -// pointing oclif config options to lib/ instead of build/ +// pointing oclif config options to src/ instead of build/ modifyOclifPaths(); // Undo changes on exit process.on('exit', function () { @@ -57,9 +57,9 @@ require('ts-node').register({ project: path.join(rootDir, 'tsconfig.json'), transpileOnly: true, }); -require('../lib/app').run(undefined, { dir: __dirname, development: true }); +require('../src/app').run(undefined, { dir: __dirname, development: true }); -// Modify package.json oclif paths from build/ -> lib/, or vice versa +// Modify package.json oclif paths from build/ -> src/, or vice versa function modifyOclifPaths(revert) { const fs = require('fs'); const packageJsonPath = path.join(rootDir, 'package.json'); @@ -73,9 +73,9 @@ function modifyOclifPaths(revert) { let oclifSectionText = JSON.stringify(packageObj.oclif); if (!revert) { - oclifSectionText = oclifSectionText.replace(/\/build\//g, '/lib/'); + oclifSectionText = oclifSectionText.replace(/\/build\//g, '/src/'); } else { - oclifSectionText = oclifSectionText.replace(/\/lib\//g, '/build/'); + oclifSectionText = oclifSectionText.replace(/\/src\//g, '/build/'); } packageObj.oclif = JSON.parse(oclifSectionText); diff --git a/package.json b/package.json index 4b61e19a..495fa2ae 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "bin/", "build/", "doc/", - "lib/", + "src/", "patches/", "!patches/**/**.dev.patch", "*.md", @@ -51,7 +51,7 @@ "build": "npm run build:src && npm run catch-uncommitted", "build:t": "npm run lint && npm run build:fast && npm run build:test", "build:src": "npm run lint && npm run build:fast && npm run build:test && npm run build:doc && npm run build:completion", - "build:pages": "mkdirp ./build/auth/pages/&& inline-source --compress ./lib/auth/pages/error.ejs ./build/auth/pages/error.ejs && inline-source --compress ./lib/auth/pages/success.ejs ./build/auth/pages/success.ejs", + "build:pages": "mkdirp ./build/auth/pages/&& inline-source --compress ./src/auth/pages/error.ejs ./build/auth/pages/error.ejs && inline-source --compress ./src/auth/pages/success.ejs ./build/auth/pages/success.ejs", "build:fast": "npm run build:pages && tsc && npx oclif manifest", "build:test": "tsc -P ./tsconfig.dev.json --noEmit", "build:doc": "ts-node --transpile-only automation/capitanodoc/index.ts > docs/balena-cli.md", @@ -73,7 +73,7 @@ "catch-uncommitted": "ts-node --transpile-only automation/run.ts catch-uncommitted", "ci": "npm run test && npm run catch-uncommitted", "lint": "npm run lint-tsconfig && npm run lint-other", - "lint-tsconfig": "balena-lint -e ts -e js -t tsconfig.dev.json --fix automation/ lib/ tests/ typings/", + "lint-tsconfig": "balena-lint -e ts -e js -t tsconfig.dev.json --fix automation/ src/ tests/ typings/", "lint-other": "balena-lint -e ts -e js --fix bin/run.js bin/dev.js completion/ .mocharc.js .mocharc-standalone.js", "update": "ts-node --transpile-only ./automation/update-module.ts", "prepare": "echo {} > bin/.fast-boot.json", diff --git a/src/events.ts b/src/events.ts index fd0f74f6..3aa2826a 100644 --- a/src/events.ts +++ b/src/events.ts @@ -30,7 +30,7 @@ import { stripIndent } from './utils/lazy'; * * The username and command signature are also added as extra context * information in Sentry.io error reporting, for CLI debugging purposes - * (mainly unexpected/unhandled exceptions -- see also `lib/errors.ts`). + * (mainly unexpected/unhandled exceptions -- see also `src/errors.ts`). * * For more details on the data collected by balena generally, check this page: * https://www.balena.io/docs/learn/more/collected-data/ diff --git a/src/fast-boot.ts b/src/fast-boot.ts index d66dd499..f178fdb6 100644 --- a/src/fast-boot.ts +++ b/src/fast-boot.ts @@ -20,7 +20,7 @@ * we have permissions over the cache file before even attempting to load * fast boot. * DON'T IMPORT BALENA-CLI MODULES HERE, as this module is loaded directly - * from `bin/run.js`, before the CLI's entrypoint in `lib/app.ts`. + * from `bin/run.js`, before the CLI's entrypoint in `src/app.ts`. */ import * as fs from 'fs'; @@ -63,7 +63,7 @@ async function $start() { process.env.BALENARC_DATA_DIRECTORY || path.join(os.homedir(), dotBalena), ); // Consider that the CLI may be installed to a folder owned by root - // such as `/usr[/local]/lib/balena-cli`, while being executed by + // such as `/usr[/local]/src/balena-cli`, while being executed by // a regular user account. const cacheFile = path.join(dataDir, 'cli-module-cache.json'); const root = path.join(__dirname, '..'); diff --git a/src/utils/bootstrap.ts b/src/utils/bootstrap.ts index bcf5c587..679e66f3 100644 --- a/src/utils/bootstrap.ts +++ b/src/utils/bootstrap.ts @@ -130,8 +130,8 @@ let cachedUsername: CachedUsername | undefined; /** * Return the parsed contents of the `~/.balena/cachedUsername` file. If the file * does not exist, create it with the details from the cloud. If not connected - * to the internet, return undefined. This function is used by `lib/events.ts` - * (event tracking) and `lib/utils/device/ssh.ts` and needs to gracefully handle + * to the internet, return undefined. This function is used by `src/events.ts` + * (event tracking) and `src/utils/device/ssh.ts` and needs to gracefully handle * the scenario of not being connected to the internet. */ export async function getCachedUsername(): Promise { diff --git a/tests/utils/device/live.spec.ts b/tests/utils/device/live.spec.ts index 844c01d2..6ca79bb6 100644 --- a/tests/utils/device/live.spec.ts +++ b/tests/utils/device/live.spec.ts @@ -21,7 +21,7 @@ import { promises as fs } from 'fs'; import * as path from 'path'; import { promisify } from 'util'; -import { LivepushManager } from '../../../lib/utils/device/live'; +import { LivepushManager } from '../../../src/utils/device/live'; import { resetDockerignoreCache } from '../../docker-build'; import { setupDockerignoreTestData } from '../../projects'; @@ -42,11 +42,11 @@ class MockLivepushManager extends LivepushManager { composition: { version: '2.1', services: {} }, buildTasks: [], docker: {} as import('dockerode'), - api: {} as import('../../../lib/utils/device/api').DeviceAPI, - logger: {} as import('../../../lib/utils/logger'), + api: {} as import('../../../src/utils/device/api').DeviceAPI, + logger: {} as import('../../../src/utils/logger'), imageIds: {}, deployOpts: - {} as import('../../../lib/utils/device/deploy').DeviceDeployOptions, + {} as import('../../../src/utils/device/deploy').DeviceDeployOptions, }); } diff --git a/tsconfig.dev.json b/tsconfig.dev.json index 3b00a90e..9762f3df 100644 --- a/tsconfig.dev.json +++ b/tsconfig.dev.json @@ -6,7 +6,7 @@ }, "include": [ "./automation/**/*", - "./lib/**/*", + "./src/**/*", "./patches/*", "./tests/**/*", "./typings/**/*" diff --git a/tsconfig.json b/tsconfig.json index bfe183cb..8632c46d 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,5 +20,5 @@ ], "preserveSymlinks": true }, - "include": ["./lib/**/*", "./typings/**/*"] + "include": ["./src/**/*", "./typings/**/*"] }