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

Fix create-package script #9491

Merged
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"buildfast": "npm run _rushBuild",
"code-style": "node common/scripts/install-run-rush.js code-style",
"change": "node common/scripts/install-run-rush.js change",
"rush-update": "npm run _rushInstall && node common/scripts/install-run-rush.js update",
"rush-update": "node common/scripts/install-run-rush.js update",
"generate": "npm run rush-update",
"bundlesize": "cd scripts && npm run bundlesize",
"bundlesizecollect": "cd scripts && npx just-scripts bundle-size-collect",
Expand Down
130 changes: 104 additions & 26 deletions scripts/create-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,102 @@ const experimentsPackageJson = JSON.parse(fs.readFileSync(experimentsPackagePath

// Steps (mustache template names and output file paths)
const steps = [
{ template: 'NpmIgnore', output: '.npmignore' },
KevinTCoughlin marked this conversation as resolved.
Show resolved Hide resolved
{ template: 'Npmrc', output: '.npmrc' },
{ template: 'ChangelogJson', output: 'CHANGELOG.json' },
{ template: 'ChangelogMarkdown', output: 'CHANGELOG.md' },
{ template: 'License', output: 'LICENSE' },
{ template: 'Readme', output: 'README.md' },
{ template: 'IndexHtml', output: 'index.html' },
{ template: 'JestConfig', output: 'jest.config.js' },
{ template: 'JestDomConfig', output: 'jest.dom.config.js' },
{ template: 'JsConfig', output: 'jsconfig.json' },
{ template: 'PackageJson', output: 'package.json' },
{ template: 'PrettierConfig', output: 'prettier.config.js' },
{ template: 'TsConfig', output: 'tsconfig.json' },
{ template: 'TsLint', output: 'tslint.json' },
{ template: 'WebpackConfig', output: 'webpack.config.js' },
{ template: 'WebpackServeConfig', output: 'webpack.serve.config.js' },
{ template: 'Tests', output: path.join('config', 'tests.js') },
{ template: 'PreCopy', output: path.join('config', 'pre-copy.json') },
{ template: 'Tests', output: path.join('src', 'common', 'tests.js') },
{ template: 'IndexTs', output: path.join('src', 'index.ts') },
{ template: 'Version', output: path.join('src', 'version.ts') },
{ template: 'AppDefinition', output: path.join('src', 'demo', 'AppDefinition.tsx') },
{ template: 'GettingStartedPage', output: path.join('src', 'demo', 'GettingStartedPage.tsx') },
{ template: 'Demo', output: path.join('src', 'demo', 'index.tsx') }
{
template: 'NpmIgnore',
output: '.npmignore'
},
{
template: 'Npmrc',
output: '.npmrc'
},
{
template: 'ChangelogJson',
output: 'CHANGELOG.json'
},
{
template: 'ChangelogMarkdown',
output: 'CHANGELOG.md'
},
{
template: 'License',
output: 'LICENSE'
},
{
template: 'Readme',
output: 'README.md'
},
{
template: 'IndexHtml',
output: 'index.html'
},
{
template: 'JustConfig',
output: 'just.config.js'
},
{
template: 'JestConfig',
output: 'jest.config.js'
},
{
template: 'JsConfig',
output: 'jsconfig.json'
},
{
template: 'PackageJson',
output: 'package.json'
},
{
template: 'PrettierConfig',
output: 'prettier.config.js'
},
{
template: 'TsConfig',
output: 'tsconfig.json'
},
{
template: 'TsLint',
output: 'tslint.json'
},
{
template: 'WebpackConfig',
output: 'webpack.config.js'
},
{
template: 'WebpackServeConfig',
output: 'webpack.serve.config.js'
},
{
template: 'Tests',
output: path.join('config', 'tests.js')
},
{
template: 'PreCopy',
output: path.join('config', 'pre-copy.json')
},
{
template: 'Tests',
output: path.join('src', 'common', 'tests.js')
},
{
template: 'IndexTs',
output: path.join('src', 'index.ts')
},
{
template: 'Version',
output: path.join('src', 'version.ts')
},
{
template: 'AppDefinition',
output: path.join('src', 'demo', 'AppDefinition.tsx')
},
{
template: 'GettingStartedPage',
output: path.join('src', 'demo', 'GettingStartedPage.tsx')
},
{
template: 'Demo',
output: path.join('src', 'demo', 'index.tsx')
}
];

// Strings
Expand Down Expand Up @@ -141,8 +213,14 @@ function readFileCallback(error, data, templateName, outputFilePath, callback, r
// As of writing, @uifabric/experiments also depends on all the packages the template needs,
// so we grab the current versions from there and add tags for them in the view object.
const templatePackageJson = JSON.parse(data);
const deps = { ...templatePackageJson.devDependencies, ...templatePackageJson.dependencies };
const depVersions = { ...experimentsPackageJson.devDependencies, ...experimentsPackageJson.dependencies };
const deps = {
...templatePackageJson.devDependencies,
...templatePackageJson.dependencies
};
const depVersions = {
...experimentsPackageJson.devDependencies,
...experimentsPackageJson.dependencies
};
const packages = Object.keys(deps);
for (const package of packages) {
if (depVersions[package]) {
Expand Down
3 changes: 3 additions & 0 deletions scripts/templates/create-package/EmptyJustConfig.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { preset } = require('@uifabric/build');

preset();
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"start": "npx just-scripts dev",
"start-test": "npx just-scripts jest-watch",
"update-snapshots": "npx just-scripts jest -u",
"just": "npx just-scripts",
"just": "npx just-scripts"
KevinTCoughlin marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {
"@types/enzyme": "{{{typesEnzyme}}}",
Expand All @@ -31,6 +31,7 @@
"@types/react-dom": "{{{typesReactDom}}}",
"@types/react-test-renderer": "{{{typesReactTestRenderer}}}",
"@types/webpack-env": "{{{typesWebpackEnv}}}",
"@uifabric/build": "{{{uifabricBuild}}}",
"@uifabric/example-app-base": "{{{uifabricExampleAppBase}}}",
"@uifabric/jest-serializer-merge-styles": "{{{uifabricJestSerializerMergeStyles}}}",
"@uifabric/prettier-rules": "{{{uifabricPrettierRules}}}",
Expand Down