├── .npmrc ├── packages ├── cli │ ├── README.md │ ├── bin.js │ ├── src │ │ ├── errors.ts │ │ ├── logger.ts │ │ └── index.ts │ ├── package.json │ └── CHANGELOG.md ├── source-comments │ ├── src │ │ ├── __fixtures__ │ │ │ ├── todo.js │ │ │ ├── fixme.js │ │ │ └── question.js │ │ ├── index.test.ts │ │ ├── __snapshots__ │ │ │ └── index.test.ts.snap │ │ └── index.ts │ ├── package.json │ └── CHANGELOG.md ├── react │ ├── src │ │ ├── popover │ │ │ ├── index.ts │ │ │ ├── popover.ts │ │ │ ├── popper.ts │ │ │ └── utils.ts │ │ ├── index.ts │ │ ├── marking │ │ │ ├── NoteContext.ts │ │ │ ├── Note.tsx │ │ │ └── NotePanel.tsx │ │ ├── icons.tsx │ │ └── tokens.ts │ ├── package.json │ └── CHANGELOG.md ├── source-react │ ├── src │ │ ├── __fixtures__ │ │ │ ├── without-purpose.js │ │ │ ├── with-purpose-fixme.js │ │ │ ├── with-purpose-todo.js │ │ │ ├── with-purpose-question.js │ │ │ ├── with-child-comp.js │ │ │ └── with-child-func.js │ │ ├── index.test.ts │ │ ├── __snapshots__ │ │ │ └── index.test.ts.snap │ │ └── index.ts │ ├── package.json │ └── CHANGELOG.md ├── test-utils │ ├── src │ │ ├── index.ts │ │ └── run-fixtures.ts │ ├── package.json │ └── CHANGELOG.md ├── types │ ├── source │ │ └── package.json │ ├── src │ │ ├── source.ts │ │ └── index.ts │ ├── package.json │ └── CHANGELOG.md ├── output-json │ ├── src │ │ └── index.ts │ ├── package.json │ └── CHANGELOG.md ├── output-csv │ ├── src │ │ └── index.ts │ ├── package.json │ └── CHANGELOG.md └── output-html │ ├── package.json │ ├── src │ ├── index.tsx │ ├── icons.tsx │ ├── tokens.ts │ └── NotePanel.tsx │ └── CHANGELOG.md ├── pnpm-workspace.yaml ├── test-project ├── next.config.js ├── next-env.d.ts ├── test-file.tsx ├── tsconfig.json ├── pages │ ├── _app.js │ ├── index.css │ └── index.tsx ├── package.json └── CHANGELOG.md ├── .gitignore ├── babel.config.js ├── .changeset ├── config.json └── README.md ├── .github └── workflows │ ├── main.yml │ └── changeset-release.yml ├── package.json ├── README.md └── tsconfig.json /.npmrc: -------------------------------------------------------------------------------- 1 | save-workspace-protocol = false -------------------------------------------------------------------------------- /packages/cli/README.md: -------------------------------------------------------------------------------- 1 | # @markings/cli 2 | -------------------------------------------------------------------------------- /packages/source-comments/src/__fixtures__/todo.js: -------------------------------------------------------------------------------- 1 | // TODO: thing 2 | -------------------------------------------------------------------------------- /packages/source-comments/src/__fixtures__/fixme.js: -------------------------------------------------------------------------------- 1 | // FIXME: something 2 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - "packages/*" 3 | - "test-project" 4 | -------------------------------------------------------------------------------- /packages/react/src/popover/index.ts: -------------------------------------------------------------------------------- 1 | export { usePopover } from "./popover"; 2 | -------------------------------------------------------------------------------- /packages/source-comments/src/__fixtures__/question.js: -------------------------------------------------------------------------------- 1 | // QUESTION: a question 2 | -------------------------------------------------------------------------------- /test-project/next.config.js: -------------------------------------------------------------------------------- 1 | module.exports = require("@preconstruct/next")(); 2 | -------------------------------------------------------------------------------- /packages/cli/bin.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | "use strict"; 3 | 4 | require("."); 5 | -------------------------------------------------------------------------------- /packages/react/src/index.ts: -------------------------------------------------------------------------------- 1 | export { MarkingProvider, Marking } from "./marking/Note"; 2 | -------------------------------------------------------------------------------- /packages/source-react/src/__fixtures__/without-purpose.js: -------------------------------------------------------------------------------- 1 | ; 2 | -------------------------------------------------------------------------------- /packages/test-utils/src/index.ts: -------------------------------------------------------------------------------- 1 | export { snapshotMarkingsFromFixtures } from "./run-fixtures"; 2 | -------------------------------------------------------------------------------- /test-project/next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /packages/source-react/src/__fixtures__/with-purpose-fixme.js: -------------------------------------------------------------------------------- 1 | ; 2 | -------------------------------------------------------------------------------- /packages/source-react/src/__fixtures__/with-purpose-todo.js: -------------------------------------------------------------------------------- 1 | ; 2 | -------------------------------------------------------------------------------- /packages/types/source/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "main": "dist/types.cjs.js", 3 | "module": "dist/types.esm.js" 4 | } 5 | -------------------------------------------------------------------------------- /packages/source-react/src/__fixtures__/with-purpose-question.js: -------------------------------------------------------------------------------- 1 | ; 2 | -------------------------------------------------------------------------------- /packages/source-react/src/__fixtures__/with-child-comp.js: -------------------------------------------------------------------------------- 1 | 2 | Hi 3 | ; 4 | -------------------------------------------------------------------------------- /packages/source-react/src/__fixtures__/with-child-func.js: -------------------------------------------------------------------------------- 1 | 2 | {(props) => Hi} 3 | ; 4 | -------------------------------------------------------------------------------- /packages/source-react/src/index.test.ts: -------------------------------------------------------------------------------- 1 | import { snapshotMarkingsFromFixtures } from "@markings/test-utils"; 2 | import { source } from "."; 3 | 4 | snapshotMarkingsFromFixtures(__dirname, source); 5 | -------------------------------------------------------------------------------- /packages/source-comments/src/index.test.ts: -------------------------------------------------------------------------------- 1 | import { snapshotMarkingsFromFixtures } from "@markings/test-utils"; 2 | import { source } from "."; 3 | 4 | snapshotMarkingsFromFixtures(__dirname, source); 5 | -------------------------------------------------------------------------------- /packages/output-json/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Output } from "@markings/types"; 2 | 3 | export const output: Output = { 4 | getFile(markings) { 5 | return JSON.stringify(markings, null, 2); 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | *.log 4 | .cache 5 | .DS_Store 6 | public 7 | scratchings.js 8 | test-project/output.json 9 | test-project/output.csv 10 | test-project/output.html 11 | .next 12 | .vscode -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | "@babel/preset-env", 4 | "@babel/preset-typescript", 5 | "@babel/preset-react" 6 | ], 7 | plugins: ["@babel/plugin-transform-runtime"] 8 | }; 9 | -------------------------------------------------------------------------------- /packages/cli/src/errors.ts: -------------------------------------------------------------------------------- 1 | export class ExitError extends Error { 2 | code: number; 3 | constructor(code: number) { 4 | super(`The process should exit with code ${code}`); 5 | this.code = code; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test-project/test-file.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Marking } from "@markings/react"; 3 | 4 | // TODO: figure out x 5 | 6 | let x = ( 7 | 8 | content 9 | 10 | ); 11 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@0.2.1/schema.json", 3 | "changelog": [ 4 | "@changesets/changelog-github", 5 | { "repo": "Thinkmill/markings" } 6 | ], 7 | "commit": false, 8 | "linked": [], 9 | "access": "public" 10 | } 11 | -------------------------------------------------------------------------------- /packages/output-json/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@markings/output-json", 3 | "version": "0.0.9", 4 | "main": "dist/output-json.cjs.js", 5 | "module": "dist/output-json.esm.js", 6 | "license": "MIT", 7 | "repository": "https://github.com/Thinkmill/markings/tree/master/packages/output-json", 8 | "dependencies": { 9 | "@markings/types": "^0.2.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/output-csv/src/index.ts: -------------------------------------------------------------------------------- 1 | import stringifyToCsv from "csv-stringify/lib/sync"; 2 | import { Output } from "@markings/types"; 3 | 4 | export const output: Output = { 5 | getFile(markings) { 6 | return stringifyToCsv( 7 | markings.map(({ location, ...x }) => ({ 8 | ...x, 9 | filename: location.filename 10 | })), 11 | { header: true } 12 | ); 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /packages/output-csv/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@markings/output-csv", 3 | "version": "0.0.8", 4 | "main": "dist/output-csv.cjs.js", 5 | "module": "dist/output-csv.esm.js", 6 | "license": "MIT", 7 | "repository": "https://github.com/Thinkmill/markings/tree/master/packages/output-csv", 8 | "dependencies": { 9 | "@babel/runtime": "^7.8.7", 10 | "@markings/types": "^0.2.0", 11 | "csv-stringify": "^5.3.6" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test-project/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": false, 6 | "skipLibCheck": true, 7 | "forceConsistentCasingInFileNames": true, 8 | "module": "esnext", 9 | "resolveJsonModule": true, 10 | "jsx": "preserve" 11 | }, 12 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], 13 | "exclude": ["node_modules"] 14 | } 15 | -------------------------------------------------------------------------------- /packages/source-comments/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@markings/source-comments", 3 | "version": "0.1.1", 4 | "main": "dist/source-comments.cjs.js", 5 | "module": "dist/source-comments.esm.js", 6 | "license": "MIT", 7 | "repository": "https://github.com/Thinkmill/markings/tree/master/packages/source-comments", 8 | "dependencies": { 9 | "@babel/types": "^7.8.7", 10 | "@markings/test-utils": "^0.0.4", 11 | "@markings/types": "^0.2.0" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works with mono-repos or single package repos to help you verion and release your code. You can find the full documentation for it [in our repository](https://github.com/changesets/changesets) 4 | 5 | We have a quick list of common questions to get you started engaging with this project in [our documentation](https://github.com/changesets/changesets/blob/master/docs/common-questions.md) 6 | -------------------------------------------------------------------------------- /packages/types/src/source.ts: -------------------------------------------------------------------------------- 1 | // this is in a different entrypoint because importing the Babel types is EXPENSIVE(I've seen it take ~10 seconds to type check) 2 | // and it's not providing value to people who aren't writing their own source 3 | // but the main entrypoint will be used 4 | 5 | import { PartialMarking } from "."; 6 | import { Visitor } from "@babel/traverse"; 7 | 8 | export type Source = { 9 | type: "babel"; 10 | visitor: Visitor<{ 11 | addMarking: (marking: PartialMarking) => void; 12 | }>; 13 | }; 14 | -------------------------------------------------------------------------------- /packages/types/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@markings/types", 3 | "version": "0.2.0", 4 | "main": "dist/types.cjs.js", 5 | "module": "dist/types.esm.js", 6 | "license": "MIT", 7 | "repository": "https://github.com/Thinkmill/markings/tree/master/packages/types", 8 | "dependencies": { 9 | "@babel/traverse": "^7.8.6", 10 | "@babel/types": "^7.8.7", 11 | "@types/babel__traverse": "^7.0.9" 12 | }, 13 | "preconstruct": { 14 | "entrypoints": [ 15 | "index.ts", 16 | "source.ts" 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/source-react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@markings/source-react", 3 | "version": "0.2.1", 4 | "main": "dist/source-react.cjs.js", 5 | "module": "dist/source-react.esm.js", 6 | "license": "MIT", 7 | "repository": "https://github.com/Thinkmill/markings/tree/master/packages/source-react", 8 | "dependencies": { 9 | "@babel/runtime": "^7.8.7", 10 | "@babel/traverse": "^7.8.6", 11 | "@babel/types": "^7.8.7", 12 | "@markings/test-utils": "^0.0.4", 13 | "@markings/types": "^0.2.0", 14 | "@types/babel__traverse": "^7.0.9" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/output-html/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@markings/output-html", 3 | "version": "0.2.1", 4 | "main": "dist/output-html.cjs.js", 5 | "module": "dist/output-html.esm.js", 6 | "files": [ 7 | "dist/*", 8 | "!**/*.d.ts" 9 | ], 10 | "license": "MIT", 11 | "repository": "https://github.com/Thinkmill/markings/tree/master/packages/output-html", 12 | "dependencies": { 13 | "@babel/runtime": "^7.8.7", 14 | "@emotion/react": "^11.0.0", 15 | "@markings/types": "^0.2.0", 16 | "react": "^16.13.0", 17 | "react-dom": "^16.13.0" 18 | }, 19 | "devDependencies": { 20 | "@types/react": "^16.9.23", 21 | "@types/react-dom": "^16.9.5" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /test-project/pages/_app.js: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { MarkingProvider } from "@markings/react"; 3 | 4 | import "./index.css"; 5 | 6 | const config = { 7 | resolveIssueCreatePath: ({ description, purpose }) => 8 | `https://github.com/thinkmill/markings/issues/new?title=${purpose}&body=${encodeURIComponent( 9 | description 10 | )}`, 11 | resolveIssuePath: (id) => 12 | `https://github.com/thinkmill/markings/issues/${id}`, 13 | resolvePrPath: (id) => `https://github.com/thinkmill/markings/pull/${id}`, 14 | }; 15 | 16 | export default ({ Component, pageProps }) => ( 17 | 18 | 19 | 20 | ); 21 | -------------------------------------------------------------------------------- /test-project/pages/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | /* color: #344563; 3 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", 4 | "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", 5 | sans-serif; */ 6 | margin: 0; 7 | font-feature-settings: "liga"; 8 | text-rendering: optimizelegibility; 9 | -webkit-font-smoothing: antialiased; 10 | -moz-osx-font-smoothing: grayscale; 11 | } 12 | 13 | code { 14 | font-family: Menlo, Monaco, Consolas, "Courier New", monospace; 15 | } 16 | 17 | img { 18 | max-width: 100%; 19 | } 20 | 21 | .stack { 22 | display: flex; 23 | flex-direction: column; 24 | } 25 | 26 | .stack > *:not(style) ~ *:not(style) { 27 | margin-top: 1rem; 28 | } 29 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | 9 | jobs: 10 | typescript: 11 | name: TypeScript 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@master 15 | 16 | - name: Set Node.js 14.x 17 | uses: actions/setup-node@master 18 | with: 19 | node-version: 14.x 20 | 21 | - uses: actions/cache@v1 22 | with: 23 | path: ~/.pnpm-store 24 | key: pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} 25 | restore-keys: pnpm- 26 | 27 | - name: Install pnpm 28 | run: npm i -g pnpm 29 | 30 | - name: Install Dependencies 31 | run: pnpm i 32 | 33 | - name: Check Types 34 | run: pnpm run types 35 | -------------------------------------------------------------------------------- /packages/react/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@markings/react", 3 | "version": "0.5.1", 4 | "main": "dist/react.cjs.js", 5 | "module": "dist/react.esm.js", 6 | "license": "MIT", 7 | "repository": "https://github.com/Thinkmill/markings/tree/master/packages/react", 8 | "dependencies": { 9 | "@babel/runtime": "^7.8.7", 10 | "@emotion/hash": "^0.8.0", 11 | "@emotion/react": "^11.0.0", 12 | "@markings/types": "^0.2.0", 13 | "@popperjs/core": "^2.0.6" 14 | }, 15 | "peerDependencies": { 16 | "@types/react": "*", 17 | "@types/react-dom": "*", 18 | "react": "^16.13.0", 19 | "react-dom": "^16.13.0" 20 | }, 21 | "devDependencies": { 22 | "@types/react": "^16.9.23", 23 | "@types/react-dom": "^16.9.5", 24 | "react": "^16.13.0", 25 | "react-dom": "^16.13.0" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /packages/source-comments/src/__snapshots__/index.test.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`fixme 1`] = ` 4 | // FIXME: something 5 | 6 | ↓ ↓ ↓ ↓ ↓ ↓ 7 | 8 | [ 9 | { 10 | "description": "something", 11 | "purpose": "fixme", 12 | "location": { 13 | "line": 1 14 | } 15 | } 16 | ] 17 | `; 18 | 19 | exports[`question 1`] = ` 20 | // QUESTION: a question 21 | 22 | ↓ ↓ ↓ ↓ ↓ ↓ 23 | 24 | [ 25 | { 26 | "description": "a question", 27 | "purpose": "question", 28 | "location": { 29 | "line": 1 30 | } 31 | } 32 | ] 33 | `; 34 | 35 | exports[`todo 1`] = ` 36 | // TODO: thing 37 | 38 | ↓ ↓ ↓ ↓ ↓ ↓ 39 | 40 | [ 41 | { 42 | "description": "thing", 43 | "purpose": "todo", 44 | "location": { 45 | "line": 1 46 | } 47 | } 48 | ] 49 | `; 50 | -------------------------------------------------------------------------------- /packages/output-html/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Output } from "@markings/types"; 3 | import { renderToStaticMarkup } from "react-dom/server"; 4 | import { NotePanel } from "./NotePanel"; 5 | 6 | export const output: Output = { 7 | getFile(markings) { 8 | return ` 9 | 10 | 11 | 12 | 16 | 20 | 21 | 22 | ${renderToStaticMarkup()} 23 | 24 | `; 25 | } 26 | }; 27 | -------------------------------------------------------------------------------- /packages/types/src/index.ts: -------------------------------------------------------------------------------- 1 | export const PURPOSES = ["question", "todo", "fixme"] as const; 2 | 3 | export type Purpose = typeof PURPOSES[number]; 4 | 5 | export type RecordOfPurposes = { [index: string]: Purpose }; 6 | 7 | export type PartialMarking = { 8 | location: { 9 | line: number; 10 | }; 11 | purpose: Purpose; 12 | description: string; 13 | }; 14 | 15 | export type Marking = { 16 | location: { 17 | line: number; 18 | filename: string; 19 | link?: string; 20 | }; 21 | purpose: Purpose; 22 | description: string; 23 | source: string; 24 | package: string; 25 | }; 26 | 27 | export type Output = { 28 | getFile: (markings: Marking[]) => Promise | string; 29 | }; 30 | 31 | export type Config = { 32 | sources: { 33 | source: string; 34 | include: string[]; 35 | }[]; 36 | outputs: { 37 | output: string; 38 | filename: string; 39 | }[]; 40 | }; 41 | -------------------------------------------------------------------------------- /packages/cli/src/logger.ts: -------------------------------------------------------------------------------- 1 | import chalk from "chalk"; 2 | import util from "util"; 3 | 4 | export function format( 5 | args: Array, 6 | messageType: "error" | "success" | "info", 7 | scope?: string 8 | ) { 9 | let prefix = { 10 | error: chalk.red("error"), 11 | success: chalk.green("success"), 12 | info: chalk.cyan("info") 13 | }[messageType]; 14 | let fullPrefix = "📝 " + prefix + (scope === undefined ? "" : " " + scope); 15 | return ( 16 | fullPrefix + 17 | util 18 | .format("", ...args) 19 | .split("\n") 20 | .join("\n" + fullPrefix + " ") 21 | ); 22 | } 23 | export function error(message: string, scope?: string) { 24 | console.error(format([message], "error", scope)); 25 | } 26 | 27 | export function success(message: string, scope?: string) { 28 | console.log(format([message], "success", scope)); 29 | } 30 | 31 | export function info(message: string, scope?: string) { 32 | console.log(format([message], "info", scope)); 33 | } 34 | -------------------------------------------------------------------------------- /packages/test-utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@markings/test-utils", 3 | "version": "0.0.4", 4 | "main": "dist/test-utils.cjs.js", 5 | "module": "dist/test-utils.esm.js", 6 | "license": "MIT", 7 | "dependencies": { 8 | "@babel/core": "^7.9.6", 9 | "@babel/parser": "^7.8.6", 10 | "@babel/runtime": "^7.8.7", 11 | "@babel/traverse": "^7.8.6", 12 | "@manypkg/get-packages": "^1.0.0", 13 | "@markings/types": "^0.2.0", 14 | "@types/babel__core": "^7.1.6", 15 | "@types/babel__traverse": "^7.0.9", 16 | "@types/jest-in-case": "^1.0.1", 17 | "@types/parse-github-url": "^1.0.0", 18 | "chalk": "^2.4.2", 19 | "fs-extra": "^8.1.0", 20 | "globby": "^11.0.0", 21 | "jest-in-case": "^1.0.2", 22 | "meow": "^5.0.0", 23 | "normalize-path": "^3.0.0", 24 | "p-limit": "^2.2.1", 25 | "parse-github-url": "^1.0.2" 26 | }, 27 | "devDependencies": { 28 | "fixturez": "^1.1.0", 29 | "strip-ansi": "^6.0.0" 30 | }, 31 | "repository": "https://github.com/Thinkmill/markings/tree/master/packages/test-utils" 32 | } 33 | -------------------------------------------------------------------------------- /packages/react/src/marking/NoteContext.ts: -------------------------------------------------------------------------------- 1 | import { createContext, useContext } from "react"; 2 | 3 | import { Purpose } from "@markings/types"; 4 | 5 | type IssueId = number | string; 6 | 7 | export type MarkingType = { 8 | description: string; 9 | issue?: IssueId; 10 | purpose: Purpose; 11 | }; 12 | 13 | export type ConfigType = { 14 | resolveIssueCreatePath: ({ 15 | description, 16 | purpose, 17 | }: { 18 | description: string; 19 | purpose: Purpose; 20 | }) => string; 21 | resolveIssuePath: (id: IssueId) => string; 22 | resolvePrPath: (id: IssueId) => string; 23 | }; 24 | export type ContextType = { 25 | enabled: boolean; 26 | register: (id: string, props: MarkingType) => string | undefined; 27 | unregister: (id: string) => void; 28 | }; 29 | 30 | export const MarkingContext = createContext(undefined); 31 | 32 | export const useMarkingRegistry = () => { 33 | const ctx = useContext(MarkingContext); 34 | if (!ctx) { 35 | throw Error("You must wrap the app with the MarkingProvider."); 36 | } 37 | return ctx; 38 | }; 39 | -------------------------------------------------------------------------------- /packages/cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@markings/cli", 3 | "version": "0.0.14", 4 | "main": "dist/cli.cjs.js", 5 | "module": "dist/cli.esm.js", 6 | "license": "MIT", 7 | "bin": { 8 | "markings": "./bin.js" 9 | }, 10 | "dependencies": { 11 | "@babel/core": "^7.9.6", 12 | "@babel/parser": "^7.8.6", 13 | "@babel/runtime": "^7.8.7", 14 | "@babel/traverse": "^7.8.6", 15 | "@manypkg/get-packages": "^1.0.0", 16 | "@markings/types": "^0.2.0", 17 | "@types/babel__core": "^7.1.6", 18 | "@types/babel__traverse": "^7.0.9", 19 | "@types/normalize-path": "^3.0.0", 20 | "@types/parse-github-url": "^1.0.0", 21 | "chalk": "^2.4.2", 22 | "fs-extra": "^8.1.0", 23 | "globby": "^11.0.0", 24 | "meow": "^5.0.0", 25 | "normalize-path": "^3.0.0", 26 | "p-limit": "^2.2.1", 27 | "parse-bitbucket-url": "^0.3.0", 28 | "parse-github-url": "^1.0.2" 29 | }, 30 | "devDependencies": { 31 | "fixturez": "^1.1.0", 32 | "strip-ansi": "^6.0.0" 33 | }, 34 | "repository": "https://github.com/Thinkmill/markings/tree/master/packages/cli" 35 | } 36 | -------------------------------------------------------------------------------- /.github/workflows/changeset-release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | release: 10 | name: Release 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout Repo 14 | uses: actions/checkout@master 15 | with: 16 | fetch-depth: 0 17 | 18 | - name: Set Node.js 14.x 19 | uses: actions/setup-node@master 20 | with: 21 | node-version: 14.x 22 | 23 | - uses: actions/cache@v1 24 | with: 25 | path: ~/.pnpm-store 26 | key: pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} 27 | restore-keys: pnpm- 28 | 29 | - name: Install pnpm 30 | run: npm i -g pnpm 31 | 32 | - name: Install Dependencies 33 | run: pnpm i 34 | 35 | - name: "Create Pull Request or Publish to npm" 36 | uses: changesets/action@master 37 | with: 38 | publish: pnpm run release 39 | version: pnpm run version 40 | env: 41 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 42 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 43 | -------------------------------------------------------------------------------- /packages/source-comments/src/index.ts: -------------------------------------------------------------------------------- 1 | import { RecordOfPurposes } from "@markings/types"; 2 | import { Source } from "@markings/types/source"; 3 | 4 | import * as BabelTypes from "@babel/types"; 5 | 6 | let commentPurposes: RecordOfPurposes = { 7 | TODO: "todo", 8 | FIXME: "fixme", 9 | QUESTION: "question", 10 | }; 11 | let commentTypes = Object.keys(commentPurposes); 12 | 13 | export const source: Source = { 14 | type: "babel", 15 | visitor: { 16 | Program(path, { addMarking }) { 17 | let comments: BabelTypes.Comment[] = (path.parent as BabelTypes.File) 18 | .comments; 19 | for (let comment of comments) { 20 | if (comment.type === "CommentLine") { 21 | let value = comment.value.trim(); 22 | let match = value.match(/([^:]+):(.+)/); 23 | if (match !== null && commentTypes.includes(match[1])) { 24 | addMarking({ 25 | description: match[2].trim(), 26 | purpose: commentPurposes[match[1]], 27 | location: { 28 | line: comment.loc.start.line, 29 | }, 30 | }); 31 | } 32 | } else { 33 | // TODO: source from block comments(potentially with a jsdoc style) too 34 | } 35 | } 36 | }, 37 | }, 38 | }; 39 | -------------------------------------------------------------------------------- /packages/test-utils/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # @markings/test-utils 2 | 3 | ## 0.0.4 4 | 5 | ### Patch Changes 6 | 7 | - [`77cda5d`](https://github.com/Thinkmill/markings/commit/77cda5dd6002a52c80e2fd2888303c050c0afa4e) Thanks [@mitchellhamilton](https://github.com/mitchellhamilton)! - Use updated @markings/types 8 | 9 | - Updated dependencies [[`77cda5d`](https://github.com/Thinkmill/markings/commit/77cda5dd6002a52c80e2fd2888303c050c0afa4e)]: 10 | - @markings/types@0.2.0 11 | 12 | ## 0.0.3 13 | 14 | ### Patch Changes 15 | 16 | - Updated dependencies [[`bb5c58f`](https://github.com/Thinkmill/markings/commit/bb5c58f8f9018900574f68d7057482d067467273)]: 17 | - @markings/types@0.1.0 18 | 19 | ## 0.0.2 20 | 21 | ### Patch Changes 22 | 23 | - [`844ce8a`](https://github.com/Thinkmill/markings/commit/844ce8a4b005d167c187f8890f3e0eb8d75978ea) Thanks [@mitchellhamilton](https://github.com/mitchellhamilton)! - Update dependencies 24 | 25 | - Updated dependencies [[`844ce8a`](https://github.com/Thinkmill/markings/commit/844ce8a4b005d167c187f8890f3e0eb8d75978ea)]: 26 | - @markings/types@0.0.7 27 | 28 | ## 0.0.1 29 | 30 | ### Patch Changes 31 | 32 | - [`a417548`](https://github.com/Thinkmill/markings/commit/a4175484f2af47e9db1f17677e6d8a33066267e7) Thanks [@mitchellhamilton](https://github.com/mitchellhamilton)! - Initial Release 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@markings/repo", 3 | "version": "1.0.0", 4 | "private": true, 5 | "license": "MIT", 6 | "repository": "https://github.com/Thinkmill/markings", 7 | "dependencies": { 8 | "@babel/core": "^7.9.6", 9 | "@babel/plugin-transform-runtime": "^7.9.6", 10 | "@babel/preset-env": "^7.9.6", 11 | "@babel/preset-react": "^7.9.4", 12 | "@babel/preset-typescript": "^7.9.0", 13 | "@changesets/changelog-github": "^0.2.1", 14 | "@changesets/cli": "^2.5.2", 15 | "@manypkg/cli": "^0.13.0", 16 | "@preconstruct/cli": "^2.0.1", 17 | "@types/fs-extra": "^8.0.1", 18 | "@types/jest": "^25.1.3", 19 | "jest": "^25.1.0", 20 | "jest-watch-typeahead": "^0.4.2", 21 | "typescript": "^3.8.3" 22 | }, 23 | "jest": { 24 | "watchPlugins": [ 25 | "jest-watch-typeahead/filename", 26 | "jest-watch-typeahead/testname" 27 | ] 28 | }, 29 | "preconstruct": { 30 | "packages": [ 31 | "packages/*" 32 | ], 33 | "distFilenameStrategy": "unscoped-package-name" 34 | }, 35 | "prettier": {}, 36 | "scripts": { 37 | "preinstall": "node -e \"!process.env.npm_config_user_agent.startsWith('pnpm/') && !console.log('Use https://pnpm.js.org/ to install dependencies in this repository\\n') && process.exit(1)\"", 38 | "postinstall": "preconstruct dev && manypkg check", 39 | "version": "changeset version && pnpm install --frozen-lockfile=false", 40 | "release": "preconstruct build && changeset publish", 41 | "start": "cd test-project && pnpm run start", 42 | "test": "jest", 43 | "types": "tsc" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /packages/react/src/popover/popover.ts: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | 3 | import { useMemo, useState } from "react"; 4 | 5 | import { Modifier, Options, Placement, usePopper } from "./popper"; 6 | import { useClickOutside, useKeyPress } from "./utils"; 7 | 8 | type Modifiers = Modifier[]; 9 | 10 | // Hook 11 | // ------------------------------ 12 | 13 | export const usePopover = ( 14 | placement: Placement = "bottom", 15 | modifiers?: Modifiers 16 | ) => { 17 | const [isOpen, setOpen] = useState(false); 18 | const openPopover = () => setOpen(true); 19 | const closePopover = () => setOpen(false); 20 | 21 | // prepare popper instance 22 | const config = useMemo(() => mergePopperConfig(placement, modifiers), [ 23 | placement, 24 | modifiers 25 | ]); 26 | const [triggerRef, dialogRef] = usePopper(isOpen, config); 27 | 28 | // close on click outside 29 | useClickOutside({ 30 | handler: closePopover, 31 | refs: [triggerRef, dialogRef], 32 | listenWhen: isOpen 33 | }); 34 | 35 | // close on esc press 36 | useKeyPress({ 37 | targetKey: "Escape", 38 | downHandler: closePopover, 39 | listenWhen: isOpen 40 | }); 41 | 42 | return { isOpen, openPopover, closePopover, dialogRef, triggerRef }; 43 | }; 44 | 45 | // Utils 46 | // ------------------------------ 47 | 48 | const mergePopperConfig = ( 49 | placement: Placement, 50 | modifiers: Modifiers = [] 51 | ) => ({ 52 | placement: placement, 53 | modifiers: [ 54 | { 55 | name: "offset", 56 | options: { 57 | offset: [0, 8] 58 | } 59 | }, 60 | ...modifiers 61 | ] 62 | }); 63 | -------------------------------------------------------------------------------- /test-project/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@markings/test-project", 3 | "version": "1.1.3", 4 | "private": true, 5 | "license": "MIT", 6 | "dependencies": { 7 | "@markings/cli": "^0.0.14", 8 | "@markings/output-csv": "^0.0.8", 9 | "@markings/output-html": "^0.2.1", 10 | "@markings/output-json": "^0.0.9", 11 | "@markings/react": "^0.5.1", 12 | "@markings/source-comments": "^0.1.1", 13 | "@markings/source-react": "^0.2.1", 14 | "@preconstruct/next": "^1.0.1", 15 | "@types/node": "^13.7.7", 16 | "@types/react": "^16.9.23", 17 | "next": "^9.2.2", 18 | "react": "^16.13.0", 19 | "react-dom": "^16.13.0" 20 | }, 21 | "scripts": { 22 | "markings": "markings", 23 | "markings:inspect": "NODE_OPTIONS=--inspect-brk markings", 24 | "start": "next" 25 | }, 26 | "markings": { 27 | "sources": [ 28 | { 29 | "source": "@markings/source-react", 30 | "include": [ 31 | "test-file.tsx" 32 | ] 33 | }, 34 | { 35 | "source": "@markings/source-comments", 36 | "include": [ 37 | "test-file.tsx" 38 | ] 39 | } 40 | ], 41 | "outputs": [ 42 | { 43 | "output": "@markings/output-json", 44 | "filename": "output.json" 45 | }, 46 | { 47 | "output": "@markings/output-csv", 48 | "filename": "output.csv" 49 | }, 50 | { 51 | "output": "@markings/output-html", 52 | "filename": "output.html" 53 | } 54 | ] 55 | }, 56 | "repository": "https://github.com/Thinkmill/markings/tree/master/test-project" 57 | } 58 | -------------------------------------------------------------------------------- /packages/react/src/popover/popper.ts: -------------------------------------------------------------------------------- 1 | import { useLayoutEffect, useRef } from "react"; 2 | import { 3 | Instance, 4 | Modifier as _Modifier, 5 | Options as _Options, 6 | Placement as _Placement, 7 | createPopper 8 | } from "@popperjs/core"; 9 | 10 | export type Modifier = _Modifier; 11 | export type Options = _Options; 12 | export type Placement = _Placement; 13 | 14 | export const usePopper = (isActive = false, options: Partial) => { 15 | const referenceRef = useRef(null); // target, like