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

Add warning for smt migrations #77

Merged
merged 2 commits into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thin-tigers-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'skuba': patch
---

**configure:** Add notice for smt migrations
23 changes: 23 additions & 0 deletions docs/migrating-from-seek-module-toolkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,29 @@ You should remove workarounds such as:

- Varying the referenced path of non-JS assets based on whether the code is source or compiled (i.e. using `__filename`).

After running `skuba configure`,
double check that the `package.json` fields look sensible.
Expect something like this:

```jsonc
{
"files": ["lib*/**/*.d.ts", "lib*/**/*.js", "lib*/**/*.js.map"],
"main": "./lib-commonjs/index.js",
"main": "./lib-es2015/index.js",
"types": "./lib-types/index.d.ts"
}
```

You may test out the packaging changes by either:

- Pushing your changes to a `beta` Git branch, which releases a beta version on npm.

In a consuming repo, you can then `yarn install` the beta version to give it a whirl.

- Locally packaging with `yarn build`, then `npm pack`.

In a consuming repo, you can then `yarn add ../path/to/package.tgz` the local version to give it a whirl.

## Formatting and linting

```shell
Expand Down
6 changes: 5 additions & 1 deletion src/cli/configure/analyseDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TextProcessor, copyFiles } from '../../utils/copy';
import { log } from '../../utils/logging';
import { getSkubaVersion } from '../../utils/version';

import { diffDependencies } from './analysis/package';
import { diffDependencies, generateNotices } from './analysis/package';
import * as dependencyMutators from './dependencies';
import { formatPackage } from './processing/package';
import { DependencyDiff } from './types';
Expand Down Expand Up @@ -72,6 +72,8 @@ export const analyseDependencies = async ({
devDependencies: { ...input.devDependencies },
};

const printNotices = generateNotices(input);

const processors = Object.values(dependencyMutators).reduce<TextProcessor[]>(
(acc, mutate) => {
const newProcessors = mutate(output);
Expand Down Expand Up @@ -108,6 +110,8 @@ export const analyseDependencies = async ({
log.newline();
const hasDevDependencyDiff = logDiff(devDependencyDiff);

printNotices();

const packageJsonFilepath = path.join(destinationRoot, 'package.json');

if (!hasDependencyDiff && !hasDevDependencyDiff) {
Expand Down
31 changes: 30 additions & 1 deletion src/cli/configure/analysis/package.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import readPkgUp from 'read-pkg-up';

import { log } from '../../../utils/logging';
import { DependencyDiff } from '../types';
import { DependencyDiff, DependencySet } from '../types';

import { determineOperation } from './diff';

Expand Down Expand Up @@ -71,3 +71,32 @@ export const diffDependencies = (
...additions,
};
};

export const generateNotices = ({
dependencies,
devDependencies,
}: DependencySet) => {
if (
'@seek/seek-module-toolkit' in dependencies ||
'@seek/seek-module-toolkit' in devDependencies
) {
return () => {
log.newline();
log.plain(`👋 Hello, ${log.bold('seek-module-toolkitter')}!`);
log.newline();
log.warn(
"We're going to tweak your output directories,",
'so double check your bundle once this is done.',
);
log.newline();
log.warn(
'Read more:',
log.bold(
'https://github.com/seek-oss/skuba/blob/master/docs/migrating-from-seek-module-toolkit.md#building',
),
);
};
}

return () => {};
};
3 changes: 2 additions & 1 deletion src/cli/configure/dependencies/skubaDeps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ const DEV_DEPENDENCIES = [
'typescript',
] as const;

export const skubaDeps = ({ devDependencies }: DependencySet) => {
export const skubaDeps = ({ dependencies, devDependencies }: DependencySet) => {
DEV_DEPENDENCIES.forEach((dep) => {
delete dependencies[dep];
delete devDependencies[dep];
});

Expand Down
2 changes: 2 additions & 0 deletions src/cli/configure/getEntryPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import chalk from 'chalk';
import { Input } from 'enquirer';
import { NormalizedReadResult } from 'read-pkg-up';

import { log } from '../../utils/logging';
import { ProjectType } from '../../utils/manifest';
import { TemplateConfig } from '../../utils/template';
import { hasStringProp } from '../../utils/validation';
Expand All @@ -30,6 +31,7 @@ export const getEntryPoint = ({
return templateConfig.entryPoint;
}

log.newline();
const entryPointPrompt = new Input({
initial: type === 'package' ? 'src/index.ts' : 'src/app.ts',
message: 'Entry point:',
Expand Down
2 changes: 2 additions & 0 deletions src/cli/configure/getProjectType.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Select } from 'enquirer';
import { NormalizedReadResult } from 'read-pkg-up';

import { log } from '../../utils/logging';
import { PROJECT_TYPES, ProjectType } from '../../utils/manifest';
import { TemplateConfig } from '../../utils/template';
import { hasProp } from '../../utils/validation';
Expand Down Expand Up @@ -31,6 +32,7 @@ export const getProjectType = async ({
? 'package'
: 'application';

log.newline();
const projectTypePrompt = new Select({
choices: PROJECT_TYPES,
message: 'Project type:',
Expand Down