diff --git a/.changeset/thin-tigers-hunt.md b/.changeset/thin-tigers-hunt.md new file mode 100644 index 000000000..9b6accfb6 --- /dev/null +++ b/.changeset/thin-tigers-hunt.md @@ -0,0 +1,5 @@ +--- +'skuba': patch +--- + +**configure:** Add notice for smt migrations diff --git a/docs/migrating-from-seek-module-toolkit.md b/docs/migrating-from-seek-module-toolkit.md index b8a3c0ff5..1a632adc3 100644 --- a/docs/migrating-from-seek-module-toolkit.md +++ b/docs/migrating-from-seek-module-toolkit.md @@ -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 diff --git a/src/cli/configure/analyseDependencies.ts b/src/cli/configure/analyseDependencies.ts index 2e7234848..c26207880 100644 --- a/src/cli/configure/analyseDependencies.ts +++ b/src/cli/configure/analyseDependencies.ts @@ -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'; @@ -72,6 +72,8 @@ export const analyseDependencies = async ({ devDependencies: { ...input.devDependencies }, }; + const printNotices = generateNotices(input); + const processors = Object.values(dependencyMutators).reduce( (acc, mutate) => { const newProcessors = mutate(output); @@ -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) { diff --git a/src/cli/configure/analysis/package.ts b/src/cli/configure/analysis/package.ts index ac30bc4ad..175cd3bc2 100644 --- a/src/cli/configure/analysis/package.ts +++ b/src/cli/configure/analysis/package.ts @@ -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'; @@ -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 () => {}; +}; diff --git a/src/cli/configure/dependencies/skubaDeps.ts b/src/cli/configure/dependencies/skubaDeps.ts index 1f4f17621..7ca653f4f 100644 --- a/src/cli/configure/dependencies/skubaDeps.ts +++ b/src/cli/configure/dependencies/skubaDeps.ts @@ -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]; }); diff --git a/src/cli/configure/getEntryPoint.ts b/src/cli/configure/getEntryPoint.ts index 1cd184fbb..6d15ff387 100644 --- a/src/cli/configure/getEntryPoint.ts +++ b/src/cli/configure/getEntryPoint.ts @@ -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'; @@ -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:', diff --git a/src/cli/configure/getProjectType.ts b/src/cli/configure/getProjectType.ts index 56f02b4af..6bf2e29be 100644 --- a/src/cli/configure/getProjectType.ts +++ b/src/cli/configure/getProjectType.ts @@ -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'; @@ -31,6 +32,7 @@ export const getProjectType = async ({ ? 'package' : 'application'; + log.newline(); const projectTypePrompt = new Select({ choices: PROJECT_TYPES, message: 'Project type:',