Skip to content

Commit

Permalink
Merge pull request #68 from rxdi/67-non-matching-folder-names
Browse files Browse the repository at this point in the history
fix(): removed namespacing and instead we use provided folder from fireDependencies the tool resolves now any package not only monorepo packages
  • Loading branch information
Stradivario authored Mar 6, 2023
2 parents 80ad4d1 + 2184330 commit 72edadb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ There are multiple binaries for `mac`, `windows` and `linux`
There is only one tested in `linux` so keep in mind that for `mac` and `windows` may not work!
If the binaries don't work in `mac` or `windows` please install it via `npm` globally with `npm i -g @rxdi/firelink`

The tool assumes `@group/package-name` naming convention

## Usage

#### Add `fireDependencies` inside `package.json`
Expand Down Expand Up @@ -173,6 +171,8 @@ Equivalent of excludes inside package.json `.fireignore` can be specified as a f

If you do not wish to use `.fireignore` file name the name can be specified from `fireConfig.excludesFileName`

You can pass `--runner dir` argument to the command which will override the default runner `firebase`

By default packages will be saved in `.packages` folder and `current` directory will be used
U can change that by specifiyng properties `outFolderName` and `outFolderLocation` inside `fireConfig`
Check `example` folder inside this repository
Expand Down
10 changes: 7 additions & 3 deletions src/create-virtual-symlink.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { includes } from './helpers/args-extractors';
import { includes, nextOrDefault } from './helpers/args-extractors';
import { buildPackages } from './helpers/build-packages';
import { copyPackages } from './helpers/copy-packages';
import { exitHandler } from './helpers/exit-handler';
Expand All @@ -22,7 +22,11 @@ export async function createVirtualSymlink(
) {
packageJson.fireConfig = packageJson.fireConfig || ({} as FireLinkConfig);
let successStatus = false;
const runner = packageJson.fireConfig.runner || DEFAULT_RUNNER;
const runner =
nextOrDefault(Tasks.RUNNER) ||
packageJson.fireConfig.runner ||
DEFAULT_RUNNER;

const excludes = [
...(packageJson.fireConfig.excludes || []),
...(await readExcludes(
Expand Down Expand Up @@ -67,7 +71,7 @@ export async function createVirtualSymlink(
),
);

await modifyJson(packageJson, dependencies, outFolder, outFolderName);
await modifyJson(packageJson, dependencies);
}

try {
Expand Down
6 changes: 2 additions & 4 deletions src/helpers/args-extractors.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { Tasks } from '../injection-tokens';

export const includes = (i: string) => process.argv.toString().includes(i);
export const nextOrDefault = (
i: string,
fb: boolean | string = true,
fb?: string,
type = (p: string) => p,
) => {
if (process.argv.toString().includes(Tasks[i])) {
if (process.argv.toString().includes(i)) {
const isNextArgumentPresent = process.argv[process.argv.indexOf(i) + 1];
if (!isNextArgumentPresent) {
return fb;
Expand Down
8 changes: 2 additions & 6 deletions src/helpers/modify-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ import {
export async function modifyJson(
packageJson: PackageJson,
dependencies: DependenciesLink[],
outFolder: string,
outFolderName: string,
) {
for (const { dep } of dependencies) {
packageJson.dependencies[dep] = `file:${outFolder}/${outFolderName}/${
dep.includes('/') ? dep.split('/')[1] : dep
}`;
for (const { dep, folder } of dependencies) {
packageJson.dependencies[dep] = `file:${folder}`;
}
await promisify(writeFile)(
WorkingFiles.PACKAGE_JSON,
Expand Down
1 change: 1 addition & 0 deletions src/injection-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export enum Tasks {
LEAVE_CHANGES = '--leave-changes',
NO_RUNNER = '--no-runner',
USE_NATIVE_COPY = '--use-native-copy',
RUNNER = '--runner',
}

export interface DependenciesLink {
Expand Down

0 comments on commit 72edadb

Please sign in to comment.