Skip to content

Commit c307950

Browse files
committed
renaming
1 parent be31ea0 commit c307950

File tree

28 files changed

+163
-204
lines changed

28 files changed

+163
-204
lines changed

azure-pipelines.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
# Add steps that analyze code, save build artifacts, deploy, and more:
44
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
55
trigger:
6-
- master
6+
- master
77
pool:
88
vmImage: 'ubuntu-latest'
99
steps:
10-
- task: NodeTool@0
11-
inputs:
12-
versionSpec: '12.13'
13-
displayName: 'Install Node.js'
14-
- script: |
15-
yarn
16-
yarn lerna-bootstrap
17-
yarn test
18-
# workingDirectory: ./packages/react-microfrontend
19-
displayName: 'npm install and test'
10+
- task: NodeTool@0
11+
inputs:
12+
versionSpec: '12.13'
13+
displayName: 'Install Node.js'
14+
- script: |
15+
yarn
16+
yarn lerna-bootstrap
17+
yarn test
18+
# workingDirectory: ./packages/react
19+
displayName: 'npm install and test'

packages/cli/scripts/build/library/library.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
const { resolveApp, appPackageJson } = require('../../utils/paths');
22
const { escapePackageName } = require('../../utils/paths');
3-
const {
4-
readJson, rm, mkdir, copyFile, writeFile,
5-
} = require('../../utils/fs');
3+
const { readJson, rm, mkdir, copyFile, writeFile } = require('../../utils/fs');
64

75
const getExtension = (file) => {
86
const parts = file.split('.');
@@ -19,15 +17,18 @@ const build = async (fileToBuild) => {
1917

2018
await copyFile(resolveApp(fileToBuild), `${buildLibFolder}/schema.${getExtension(fileToBuild)}`);
2119

22-
await writeFile(`${buildLibFolder}/index.js`, `
23-
import { CreateLib } from 'react-microfrontend';
20+
await writeFile(
21+
`${buildLibFolder}/index.js`,
22+
`
23+
import { CreateLib } from '@cmra/react';
2424
import schema from './schema';
2525
2626
export default CreateLib(schema, {
2727
apiAccess: CreateLib.BUILD_TYPE.PUBLIC_API,
2828
packageName: "${escapedPackageName}"
2929
});
30-
`);
30+
`
31+
);
3132
};
3233

3334
module.exports = build;

packages/cli/scripts/create/library.js

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const addMainLibToPackageJson = async (packageJsonPath, main) => {
1212
};
1313

1414
const createLibIndex = async (libIndexPath, name) => {
15-
const content = `import { CreateLib } from 'react-microfrontend';
15+
const content = `import { CreateLib } from '@cmra/react';
1616
import schema from './schema';
1717
1818
const api = CreateLib(schema, { apiAccess: CreateLib.BUILD_TYPE.PRIVATE_API, packageName: "${name}" });
@@ -37,43 +37,31 @@ const addBuildLibToGitIgnore = async (rootAppPath, name) => {
3737
};
3838

3939
const createLibrary = async (name, folder = '.', template = 'library') => {
40-
await explain(
41-
'Creating library',
42-
async () => {
43-
const rootAppPath = resolveApp(folder);
44-
const basePath = `${rootAppPath}/packages/${name}`;
40+
await explain('Creating library', async () => {
41+
const rootAppPath = resolveApp(folder);
42+
const basePath = `${rootAppPath}/packages/${name}`;
4543

46-
await createModule(name, template, rootAppPath, true);
47-
await addMainLibToPackageJson(`${basePath}/package.json`, './build-lib/index.js');
48-
await createLibIndex(`${basePath}/src/lib/index.js`, name);
49-
await addBuildLibToGitIgnore(rootAppPath, name);
50-
},
51-
);
44+
await createModule(name, template, rootAppPath, true);
45+
await addMainLibToPackageJson(`${basePath}/package.json`, './build-lib/index.js');
46+
await createLibIndex(`${basePath}/src/lib/index.js`, name);
47+
await addBuildLibToGitIgnore(rootAppPath, name);
48+
});
5249
};
5350

5451
const deleteUnusedFiles = async (name, folder) => {
5552
const rootAppPath = resolveApp(folder);
5653
const { execInApp } = createExecutionContext(rootAppPath, name);
5754

58-
const filesToDelete = [
59-
'src/App.*',
60-
'src/*.css',
61-
'src/serviceWorker.js',
62-
'src/setupTests.js',
63-
'src/logo.*',
64-
];
55+
const filesToDelete = ['src/App.*', 'src/*.css', 'src/serviceWorker.js', 'src/setupTests.js', 'src/logo.*'];
6556

6657
await execInApp(`rm -f ${filesToDelete.join(' ')}`);
6758
};
6859

6960
const createStandaloneLibrary = async (name, folder = '.') => {
70-
await explain(
71-
'Creating standalone library',
72-
async () => {
73-
await createLibrary(name, folder);
74-
await deleteUnusedFiles(name, folder);
75-
},
76-
);
61+
await explain('Creating standalone library', async () => {
62+
await createLibrary(name, folder);
63+
await deleteUnusedFiles(name, folder);
64+
});
7765
};
7866

7967
module.exports = {

packages/cli/scripts/create/microfrontend.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ const { writeFile } = require('../utils/fs');
55
const { explain } = require('../utils/log');
66
const { resolveApp, resolvePackageSrc } = require('../utils/paths');
77

8-
9-
const indexJsFile = packageName => `
10-
import { ExportMicrofrontend } from 'react-microfrontend';
8+
const indexJsFile = (packageName) => `
9+
import { ExportMicrofrontend } from '@cmra/react';
1110
import App from './App';
1211
1312
ExportMicrofrontend({
@@ -22,17 +21,11 @@ const createMicrofrontendWithTemplate = async (name, folder) => {
2221
};
2322

2423
const createMicrofrontend = async (name, folder = '.') => {
25-
await explain(
26-
'Creating microfrontend',
27-
() => createMicrofrontendWithTemplate(name, folder),
28-
);
24+
await explain('Creating microfrontend', () => createMicrofrontendWithTemplate(name, folder));
2925
};
3026

3127
const createMicrofrontendWithLibrary = async (name, folder = '.') => {
32-
await explain(
33-
'Creating microfrontend with library',
34-
() => createLibrary(name, folder, 'microfrontend-library'),
35-
);
28+
await explain('Creating microfrontend with library', () => createLibrary(name, folder, 'microfrontend-library'));
3629
};
3730

3831
module.exports = {

packages/cli/scripts/create/module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const createModule = async (name, template, rootAppPath) => {
2727
await copyTemplateTo(template, `${rootAppPath}/packages/${name}`);
2828

2929
await execInApp('yarn add @cmra/cli');
30-
await execInApp('yarn add react-microfrontend');
30+
await execInApp('yarn add @cmra/react');
3131

3232
await addScriptsToPackageJson(
3333
`${rootAppPath}/packages/${name}/package.json`,

packages/cli/templates/library/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { ExportMicrofrontend } from '@cmra/react';
12
import schema from './lib/schema';
2-
import { ExportMicrofrontend } from 'react-microfrontend';
33

44
ExportMicrofrontend({
55
...schema,

packages/cli/templates/library/src/lib/schema.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CreateLib } from 'react-microfrontend';
1+
import { CreateLib } from '@cmra/react';
22

33
export default {
44
interface: {

packages/cli/templates/microfrontend-library/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ExportMicrofrontend } from 'react-microfrontend';
1+
import { ExportMicrofrontend } from '@cmra/react';
22
import schema from './lib/schema';
33
import App from './App';
44

packages/cli/templates/microfrontend-library/src/lib/schema.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CreateLib } from 'react-microfrontend';
1+
import { CreateLib } from '@cmra/react';
22

33
export default {
44
interface: {

packages/cli/templates/webapp/src/App.js

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { withMicrofrontend } from 'react-microfrontend';
1+
import { withMicrofrontend } from '@cmra/react';
22

33
import React, { useState } from 'react';
44

@@ -19,26 +19,22 @@ const App = ({ microfrontends }) => {
1919
Choose a microfrontend to show:
2020
</p>
2121
<div className="App__menu">
22-
{
23-
Object.keys(microfrontends).map(microfrontend => (
24-
<button
25-
onClick={() => setSelectedMicrofrontendKey(microfrontend)}
26-
key={microfrontend}
27-
className={`App__menu-item${microfrontend === selectedMicrofrontendKey ? ' App__menu-item--selected' : ''}`}
28-
>
29-
{microfrontend}
30-
</button>
31-
))
32-
}
22+
{Object.keys(microfrontends).map((microfrontend) => (
23+
<button
24+
onClick={() => setSelectedMicrofrontendKey(microfrontend)}
25+
key={microfrontend}
26+
className={`App__menu-item${microfrontend === selectedMicrofrontendKey ? ' App__menu-item--selected' : ''}`}
27+
>
28+
{microfrontend}
29+
</button>
30+
))}
3331
</div>
3432
<div className="App__content">
35-
{
36-
MicrofrontendComponent && (
37-
<div className="App__microfrontend-content">
38-
<MicrofrontendComponent.view />
39-
</div>
40-
)
41-
}
33+
{MicrofrontendComponent && (
34+
<div className="App__microfrontend-content">
35+
<MicrofrontendComponent.view />
36+
</div>
37+
)}
4238
</div>
4339
</div>
4440
);

0 commit comments

Comments
 (0)