Skip to content

Commit

Permalink
fix: try resolving workspace: links
Browse files Browse the repository at this point in the history
  • Loading branch information
hongaar committed Nov 24, 2022
1 parent 1570241 commit 54ae0be
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 29 deletions.
13 changes: 12 additions & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
[
"@semantic-release/npm",
{
"npmPublish": false
}
],
[
"@semantic-release/exec",
{
"publishCmd": "yarn workspaces foreach npm publish"
}
],
"@semantic-release/github",
[
"@semantic-release/git",
Expand Down
11 changes: 5 additions & 6 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
### TODOs

| Filename | line # | TODO |
| :----------------------------------------------------------------------------- | :----: | :--------------------------- |
| [packages/core/src/yarnrc.ts](packages/core/src/yarnrc.ts#L23) | 23 | etc, fix later |
| [packages/cli/src/commands/create.ts](packages/cli/src/commands/create.ts#L16) | 16 | re-enable prompts |
| [packages/cli/src/commands/list.ts](packages/cli/src/commands/list.ts#L15) | 15 | list workspaces |
| [packages/plugins/src/jest/jest.ts](packages/plugins/src/jest/jest.ts#L35) | 35 | install jest without ts-jest |
| Filename | line # | TODO |
| :------------------------------------------------------------------------- | :----: | :------------------------------------------------------------ |
| [packages/core/src/yarnrc.ts](packages/core/src/yarnrc.ts#L23) | 23 | etc, fix later |
| [packages/cli/src/commands/list.ts](packages/cli/src/commands/list.ts#L15) | 15 | list workspaces using https://yarnpkg.com/cli/workspaces/list |
| [packages/plugins/src/jest/jest.ts](packages/plugins/src/jest/jest.ts#L35) | 35 | install jest without ts-jest |
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@mokr/root",
"description": "Moker root package (dummy)",
"repository": "https://github.com/hongaar/moker",
"author": "[email protected]",
"repository": "https://github.com/hongaar/moker",
"license": "MIT",
"type": "module",
"workspaces": [
Expand Down
16 changes: 4 additions & 12 deletions packages/cli/src/commands/create.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
applyTemplate,
createMonorepo,
DEFAULT_INITIAL_VERSION,
DEFAULT_LICENSE,
DEFAULT_SCOPED,
DEFAULT_WORKSPACES_DIRECTORY,
Expand All @@ -13,13 +12,11 @@ import {
import { command } from "bandersnatch";
import { resolve } from "node:path";

// @todo: re-enable prompts

export const create = command("create")
.description("Create a new monorepo")
.argument("path", {
description: "Monorepo path, basename will be used as the monorepo name.",
// prompt: "What is the name of your monorepo?",
prompt: "What is the name of your monorepo?",
})
.option("template", {
description: "Use monorepo template",
Expand All @@ -33,23 +30,18 @@ export const create = command("create")
.option("scoped", {
description: "Use scoped packages",
boolean: true,
// prompt: "Do you want to use scoped package names?",
prompt: "Do you want to use scoped package names?",
default: DEFAULT_SCOPED,
})
.option("license", {
description: "License",
choices: ["MIT", "GPLv3"],
// prompt: "What license do you want to publish your packages with?",
prompt: "What license do you want to publish your packages with?",
default: DEFAULT_LICENSE,
})
.option("initialVersion", {
description: "Initial version",
// prompt: "What version do you want to start with?",
default: DEFAULT_INITIAL_VERSION,
})
.option("workspacesDirectory", {
description: "Workspaces directory",
// prompt: "Which directory should we save workspaces to?",
prompt: "Which directory should we save workspaces to?",
default: DEFAULT_WORKSPACES_DIRECTORY,
})
.action(async ({ path, template, plugin, ...options }) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export const list = command("list")

console.log(`Plugins: ${plugins.join(", ")}`);

// @todo: list workspaces
// @todo: list workspaces using https://yarnpkg.com/cli/workspaces/list
console.log(`Workspaces: ...`);
});
6 changes: 1 addition & 5 deletions packages/core/src/monorepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { enqueueInstallDependency, initYarn } from "./yarn.js";

export const DEFAULT_SCOPED = true;
export const DEFAULT_LICENSE = "MIT";
export const DEFAULT_INITIAL_VERSION = "0.0.0";
export const DEFAULT_WORKSPACES_DIRECTORY = "packages";

export type MonorepoPackage = Package & {
Expand All @@ -31,7 +30,6 @@ export async function createMonorepo({
directory,
scoped = DEFAULT_SCOPED,
license = DEFAULT_LICENSE,
initialVersion = DEFAULT_INITIAL_VERSION,
workspacesDirectory = DEFAULT_WORKSPACES_DIRECTORY,
}: CreateMonorepoOptions) {
if (await isReadableAndWritableDirectory({ directory })) {
Expand All @@ -43,9 +41,7 @@ export async function createMonorepo({
await writePackage({
directory,
data: {
private: true,
license,
version: initialVersion,
workspaces: [`${workspacesDirectory}/*`],
moker: {
scoped,
Expand All @@ -60,7 +56,7 @@ export async function createMonorepo({

enqueueInstallDependency({
directory,
identifier: "@mokr/cli",
identifier: "moker",
dev: true,
});
}
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ type DirOption = {
directory: string;
};

const DEFAULT_INITIAL_VERSION = "0.0.0";

export async function addWorkspace({
directory,
name,
Expand All @@ -33,9 +35,10 @@ export async function addWorkspace({
append: false,
data: {
name: packageName,
version: pkg.version,
version: DEFAULT_INITIAL_VERSION,
license: pkg.license,
author: pkg.author,
repository: pkg.repository,
...(isScoped
? {
publishConfig: {
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ export async function initYarn({ directory }: DirOption) {
await addYarnPlugin({ directory, name: "interactive-tools" });

await addYarnPlugin({ directory, name: "workspace-tools" });

await addYarnPlugin({ directory, name: "version" });
}

export async function addYarnPlugin({
Expand Down

0 comments on commit 54ae0be

Please sign in to comment.