Skip to content

Commit

Permalink
Support Community based templates (#1408)
Browse files Browse the repository at this point in the history
* initial port of templates to packages

* Switch modular add setup to resolve from local packages

* Fix LICENSE for new packages

* Support community based templates

* intro modular template and templateType to solve modular check issue

* ignore lint rules for templates
  • Loading branch information
LukeSheard authored Apr 13, 2022
1 parent a3e4efe commit 162d76c
Show file tree
Hide file tree
Showing 43 changed files with 344 additions and 151 deletions.
8 changes: 8 additions & 0 deletions .changeset/gold-falcons-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"modular-scripts": minor
"modular-template-app": minor
"modular-template-view": minor
"modular-template-package": minor
---

Support Community based templates
12 changes: 6 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ module.exports = {
},
overrides: [
{
files: ['**/*.test.*', '**/__tests__/**'],
files: [
'**/*.test.*',
'**/__tests__/**',
'**/modular-template-app/**',
'**/modular-template-view/**',
],
rules: {
'import/no-extraneous-dependencies': OFF,
},
},
{
files: 'packages/modular-scripts/types/**/*',
rules: {
'react/jsx-pascal-case': OFF,
},
},
Expand Down
4 changes: 2 additions & 2 deletions packages/modular-scripts/src/__tests__/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function cleanup() {
rimraf.sync(path.join(packagesPath, 'sample-app'));
rimraf.sync(path.join(modularRoot, 'dist/sample-app'));

rimraf.sync(path.join(packagesPath, 'scoped/sample-app'));
rimraf.sync(path.join(packagesPath, 'scoped'));
rimraf.sync(path.join(modularRoot, 'dist/scoped-sample-app'));

// run yarn so yarn.lock gets reset
Expand Down Expand Up @@ -337,7 +337,7 @@ describe('when working with an app', () => {
) as CoreProperties;

expect(packageJson.name).toBe('sample-app');
expect(packageJson.version).toBe('0.1.0');
expect(packageJson.version).toBe('1.0.0');
expect(packageJson.modular).toStrictEqual({ type: 'app' });
expect(packageJson.dependencies?.react).toBeTruthy();
expect(packageJson.dependencies?.['react-dom']).toBeTruthy();
Expand Down
5 changes: 4 additions & 1 deletion packages/modular-scripts/src/__tests__/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ describe('WHEN building with preserve modules', () => {
"dist-types",
"README.md",
],
"license": "UNLICENSED",
"main": "dist-cjs/index.js",
"modular": Object {
"type": "package",
},
"module": "dist-es/index.js",
"name": "sample-async-package",
"private": false,
"typings": "dist-types/index.d.ts",
"version": "1.0.0",
}
Expand Down
10 changes: 7 additions & 3 deletions packages/modular-scripts/src/__tests__/convert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const mockedModularRoot = getModularRoot.default as jest.MockedFunction<
describe('Converting a react app to modular app', () => {
let tmpFolder: tmp.DirResult;
let tmpFolderPath: string;
const starterTempType = 'app';
const tmpProjectName = 'test-modular-convert';
const rootPackageJson: ModularPackageJson = {
name: tmpProjectName,
Expand All @@ -42,9 +41,14 @@ describe('Converting a react app to modular app', () => {
const starterFolder = ['src', 'public'];
starterFolder.forEach((dir) => {
fs.copySync(
path.join(__dirname, '..', '..', 'types', starterTempType, dir),
path.join(__dirname, '..', '..', '..', 'modular-template-app', dir),
path.join(tmpFolderPath, dir),
{ overwrite: true },
{
overwrite: true,
filter(src) {
return !(path.basename(src) === 'package.json');
},
},
);
});
fs.writeJSONSync(
Expand Down
12 changes: 9 additions & 3 deletions packages/modular-scripts/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@ describe('modular-scripts', () => {
"dist-types",
"README.md",
],
"license": "UNLICENSED",
"main": "dist-cjs/index.js",
"modular": Object {
"type": "view",
},
"module": "dist-es/index.js",
"name": "sample-view",
"private": false,
"typings": "dist-types/index.d.ts",
"version": "1.0.0",
}
Expand Down Expand Up @@ -329,10 +329,13 @@ describe('modular-scripts', () => {
"dist-types",
"README.md",
],
"license": "UNLICENSED",
"main": "dist-cjs/index.js",
"modular": Object {
"type": "package",
},
"module": "dist-es/index.js",
"name": "sample-package",
"private": false,
"typings": "dist-types/index.d.ts",
"version": "1.0.0",
}
Expand Down Expand Up @@ -398,10 +401,13 @@ describe('modular-scripts', () => {
"dist-types",
"README.md",
],
"license": "UNLICENSED",
"main": "dist-cjs/nested-sample-package.cjs.js",
"modular": Object {
"type": "package",
},
"module": "dist-es/nested-sample-package.es.js",
"name": "@nested/sample-package",
"private": false,
"typings": "dist-types/index.d.ts",
"version": "1.0.0",
}
Expand Down
10 changes: 7 additions & 3 deletions packages/modular-scripts/src/__tests__/port.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ async function setupTempModularRoot() {
mockedModularRoot.mockImplementation(() => tmpRootPath);
}

const starterTempType = 'app';
const appPackageJson: ModularPackageJson = {
name: tmpProjectName,
browserslist: {
Expand All @@ -56,9 +55,14 @@ async function setUpTempApp() {
const starterFolder = ['src', 'public'];
starterFolder.forEach((dir) => {
fs.copySync(
path.join(__dirname, '..', '..', 'types', starterTempType, dir),
path.join(__dirname, '..', '..', '..', 'modular-template-app', dir),
path.join(tmpAppPath, dir),
{ overwrite: true },
{
overwrite: true,
filter(src) {
return !(path.basename(src) === 'package.json');
},
},
);
});
fs.writeJSONSync(path.join(tmpAppPath, 'package.json'), appPackageJson, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,34 @@ Object {
"type": "app",
"workspaceDependencies": Array [],
},
"modular-template-app": Object {
"location": "packages/modular-template-app",
"mismatchedWorkspaceDependencies": Array [],
"public": true,
"type": "template",
"workspaceDependencies": Array [],
},
"modular-template-node-env-app": Object {
"location": "packages/modular-template-node-env-app",
"mismatchedWorkspaceDependencies": Array [],
"public": false,
"type": "template",
"workspaceDependencies": Array [],
},
"modular-template-package": Object {
"location": "packages/modular-template-package",
"mismatchedWorkspaceDependencies": Array [],
"public": true,
"type": "template",
"workspaceDependencies": Array [],
},
"modular-template-view": Object {
"location": "packages/modular-template-view",
"mismatchedWorkspaceDependencies": Array [],
"public": true,
"type": "template",
"workspaceDependencies": Array [],
},
"modular-views.macro": Object {
"location": "packages/modular-views.macro",
"mismatchedWorkspaceDependencies": Array [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ describe('stageView', () => {
"test-view
├─ package.json
├─ public
│ ├─ index.html #rm3xgn
│ └─ manifest.json #kalmoq
│ └─ index.html #6bixo0
├─ src
│ ├─ index.tsx #1qbgs9s
│ └─ react-app-env.d.ts #t4ygcy
│ └─ index.tsx #yuzcqd
└─ tsconfig.json #1ww9d44"
`);
});
Expand Down
Loading

0 comments on commit 162d76c

Please sign in to comment.