Skip to content

Commit

Permalink
Fixed smaller issues
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Jan 31, 2023
1 parent 52b55df commit 143d72e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Piral Changelog

## 0.15.7 (tbd)

- Fixed inconsistency with `pilet build` using explicit target while `pilet publish` using `main` from *package.json*
- Fixed reference to `piral-cli` in `piral-jest-utils`

## 0.15.6 (January 30, 2023)

- Fixed issue in `piral-cli` using the bundler without standard input (#575)
Expand Down
24 changes: 16 additions & 8 deletions src/tooling/piral-cli/src/apps/publish-pilet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { relative, dirname, basename, resolve } from 'path';
import { relative, dirname, basename, resolve, isAbsolute } from 'path';
import { callPiletBuild } from '../bundler';
import { LogLevels, PiletSchemaVersion, PiletPublishSource, PiletPublishScheme } from '../types';
import {
Expand Down Expand Up @@ -113,6 +113,11 @@ export const publishPiletDefaults: PublishPiletOptions = {
interactive: false,
};

function isSubDir(parent: string, dir: string) {
const rel = relative(parent, dir);
return rel && !rel.startsWith('..') && !isAbsolute(rel);
}

async function getFiles(
baseDir: string,
sources: Array<string>,
Expand All @@ -135,24 +140,27 @@ async function getFiles(
return await Promise.all(
allEntries.map(async (entryModule) => {
const targetDir = dirname(entryModule);

progress('Triggering pilet build ...');
const { root, piletPackage, importmap, peerDependencies, peerModules, apps } = await retrievePiletData(
targetDir,
);
const piralInstances = apps.map((m) => m.appPackage.name);
const { main = 'dist/index.js', name = 'pilet' } = piletPackage;
const dest = resolve(root, main);
const propDest = resolve(root, main);
log('generalDebug_0003', `Pilet "${name}" is supposed to generate artifact in "${propDest}".`);
const usePropDest = dirname(propDest) !== root && isSubDir(root, propDest);
const dest = usePropDest ? propDest : resolve(root, 'dist');
log('generalDebug_0003', `Pilet "${name}" is generating artifact in "${dest}".`);
const outDir = dirname(dest);
const outFile = basename(dest);
const externals = combinePiletExternals(piralInstances, peerDependencies, peerModules, importmap);
progress('Triggering pilet build ...');
log('generalDebug_0003', `Pilet "${name}" uses externals: ${externals.join(', ')}.`);

if (fresh) {
progress('Removing output directory ...');
await removeDirectory(outDir);
}
progress('Removing output directory ...');
await removeDirectory(outDir);

logInfo('Bundle pilet ...');

await callPiletBuild(
{
root,
Expand Down
5 changes: 3 additions & 2 deletions src/utilities/piral-jest-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@
"scripts": {
"cleanup": "rimraf esm lib",
"build": "yarn build:commonjs && yarn build:esnext",
"build:commonjs": "tsc --project tsconfig.json --outDir lib --module commonjs",
"build:esnext": "tsc --project tsconfig.json --outDir esm --module esnext",
"build:commonjs": "tsc --project tsconfig.json --outDir lib --module commonjs && yarn build:external --outfile=lib/utils.js --format=cjs",
"build:esnext": "tsc --project tsconfig.json --outDir esm --module esnext && yarn build:external --outfile=esm/utils.js --format=esm",
"build:external": "esbuild src/utils.ts --bundle --platform=node",
"typedoc": "typedoc --json ../../../docs/types/piral-jest-utils.json src --exclude \"src/**/*.test.*\"",
"test": "echo \"Error: run tests from root\" && exit 1"
},
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/piral-jest-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { deepMerge } from 'piral-cli/utils';
import type { Config } from '@jest/types';
import { deepMerge } from './utils';
import defaultConfig from './config';

function extendConfig(userConfig: Config.InitialOptions) {
Expand Down
1 change: 1 addition & 0 deletions src/utilities/piral-jest-utils/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { deepMerge } from 'piral-cli/src/common/merge';

0 comments on commit 143d72e

Please sign in to comment.