Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.3.1 #634

Merged
merged 12 commits into from
Oct 19, 2023
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Piral Changelog

## 1.3.1 (tbd)

- Updated behavior with unresolved inherited dependencies (#633)
- Updated behavior to only update installed dependencies on `pilet upgrade`
- Added check to prevent installing of invalid versions locally (#635)

## 1.3.0 (October 9, 2023)

- Fixed issue with global installation in pnpm (#624)
Expand Down
5 changes: 3 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ stages:
Arguments: build:demo-minimal
- task: Yarn@2
displayName: Build Landing Page
condition: ne(variables['Build.SourceBranchName'], variables['documentBranch'])
condition: eq(variables['Build.SourceBranchName'], variables['documentBranch'])
inputs:
Arguments: build:page
- task: Yarn@2
displayName: Build Documentation
condition: eq(variables['Build.SourceBranchName'], variables['documentBranch'])
inputs:
Arguments: ci:docs
- task: Yarn@2
Expand Down Expand Up @@ -758,7 +759,7 @@ stages:
- stage: DeployHomepage
displayName: Deploy Page
dependsOn: Build
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], variables['releaseBranch']))
condition: and(succeeded(), eq(variables['Build.SourceBranchName'], variables['documentBranch']))

jobs:
- deployment: DeployLandingPage
Expand Down
2 changes: 1 addition & 1 deletion docs/commands/new-piral.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Sets the tag or version of the package to install. By default, this uses the ver

- Aliases: `--piral-version`
- Type: `string`
- Default: `"1.0.2"`
- Default: `"1.3.0"`

### `--force-overwrite`

Expand Down
2 changes: 2 additions & 0 deletions docs/concepts/I08-importmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ The precedence of the lookup is:
1. See if `<inherited-name>/package.json` exists. Follow up on any `importmap` property from the file if exists.
2. See if `<inherited-name>` exists. Take it if it exists. **Note**: This has to be an importmap (JSON) then.

Dependencies that are inherited by an importmap, but not installed in the pilet will be remarked during execution of the `pilet` command of the `piral-cli` tool.

## Exclusions

Exclusions work across all inherited packages - directly and indirectly. This way, you can also make general statements about bundling. For instance, you might want to put a dependency in `exclude` that you *want* to see bundled - independent if it appears (right now) in the inherited importmaps or not.
21 changes: 21 additions & 0 deletions docs/messages/0054.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Info: 0054

Reported when an inherited dependency cannot be resolved.

## Description

When a pilet is built all the inherited (i.e., centrally shared) dependencies will be resolved. In case
you did not install one of these dependencies a short info will be shown. This acts as a reminder that
you could install more dependencies - without any runtime cost.

Note that even though shared dependencies are available at runtime in any case they will might be
for building your pilet. Therefore, if you plan to use shared dependencies please install them in your
pilet's repository.

## Example

undefined

## Further Reading

- [Piral Instance Package Definition](https://docs.piral.io/reference/documentation/C21-piral-metadata)
6 changes: 3 additions & 3 deletions src/tooling/piral-cli-webpack5/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
"strip-ansi": "^6.0.0"
},
"dependencies": {
"@babel/core": "^7.21.8",
"@babel/preset-env": "^7.21.5",
"@babel/preset-react": "^7.18.6",
"@babel/core": "^7.23.2",
"@babel/preset-env": "^7.23.2",
"@babel/preset-react": "^7.22.15",
"ansi-html-community": "0.0.8",
"babel-loader": "^9.1.3",
"cheerio": "1.0.0-rc.12",
Expand Down
129 changes: 91 additions & 38 deletions src/tooling/piral-cli/src/common/importmap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { readImportmap } from './importmap';

jest.mock('./npm', () => ({
tryResolvePackage(id, dir) {
return `${dir}/${id}/index.js`;
if (id === 'qxz') {
return undefined;
} else if (id.endsWith('package.json')) {
return `${dir}/${id}`;
} else {
return `${dir}/${id}/index.js`;
}
},
}));

Expand All @@ -15,6 +21,28 @@ const mockPackages = {
name: 'bar',
version: '1.0.0',
},
'/data/app1': {
name: 'app1',
version: '1.0.0',
importmap: {
imports: {
'[email protected]': 'foo',
},
},
},
'/data/app1/foo': {
name: 'foo',
version: '1.2.3',
},
'/data/app2': {
name: 'app1',
version: '1.0.0',
importmap: {
imports: {
'[email protected]': '',
},
},
},
};

jest.mock('./io', () => ({
Expand All @@ -33,28 +61,20 @@ jest.mock('./io', () => ({

describe('Importmap', () => {
it('reads empty one from package.json', async () => {
const deps = await readImportmap(
'/data',
{
importmap: {},
},
false,
);
const deps = await readImportmap('/data', {
importmap: {},
});
expect(deps).toEqual([]);
});

it('reads fully qualified local dependency', async () => {
const deps = await readImportmap(
'/data',
{
importmap: {
imports: {
'[email protected]': 'foo',
},
const deps = await readImportmap('/data', {
importmap: {
imports: {
'[email protected]': 'foo',
},
},
false,
);
});
expect(deps).toEqual([
{
alias: undefined,
Expand All @@ -70,17 +90,13 @@ describe('Importmap', () => {
});

it('reads fully qualified local dependency with implied exact version', async () => {
const deps = await readImportmap(
'/data',
{
importmap: {
imports: {
foo: 'foo',
},
const deps = await readImportmap('/data', {
importmap: {
imports: {
foo: 'foo',
},
},
false,
);
});
expect(deps).toEqual([
{
alias: undefined,
Expand All @@ -105,7 +121,6 @@ describe('Importmap', () => {
},
},
},
false,
'match-major',
);
expect(deps).toEqual([
Expand All @@ -132,7 +147,6 @@ describe('Importmap', () => {
},
},
},
false,
'any-patch',
);
expect(deps).toEqual([
Expand All @@ -159,7 +173,6 @@ describe('Importmap', () => {
},
},
},
false,
'all',
);
expect(deps).toEqual([
Expand All @@ -178,17 +191,57 @@ describe('Importmap', () => {

it('fails when the local version does not match the desired version', async () => {
await expect(
readImportmap(
'/data',
{
importmap: {
imports: {
'bar@^2.0.0': '',
},
readImportmap('/data', {
importmap: {
imports: {
'bar@^2.0.0': '',
},
},
}),
).rejects.toThrow();
});

it('fails when the explicitly shared package is not installed', async () => {
await expect(
readImportmap('/data', {
importmap: {
imports: {
qxz: '',
},
},
false,
),
}),
).rejects.toThrow();
});

it('accepts an importmap with valid resolvable inherited deps', async () => {
const deps = await readImportmap('/data', {
importmap: {
imports: {},
inherit: ['app1'],
},
});
expect(deps).toEqual([
{
alias: undefined,
entry: '/data/app1/foo/index.js',
id: '[email protected]',
isAsync: false,
name: 'foo',
ref: 'foo.js',
requireId: '[email protected]',
type: 'local',
parents: ['app1'],
},
]);
});

it('accepts an importmap with valid but unresolvable inherited deps', async () => {
const deps = await readImportmap('/data', {
importmap: {
imports: {},
inherit: ['app2'],
},
});
expect(deps).toEqual([]);
});
});
Loading