@quilted/create 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ import { EOL } from 'os';
4
4
  import { fileURLToPath as fileURLToPath$1 } from 'url';
5
5
  import require$$0 from 'readline';
6
6
  import require$$2 from 'events';
7
+ import require$$0$1 from 'tty';
7
8
  import path$1 from 'node:path';
8
9
  import { fileURLToPath } from 'node:url';
9
10
  import process$1 from 'node:process';
@@ -5850,79 +5851,219 @@ var arg_1 = arg;
5850
5851
 
5851
5852
  var colorette = {};
5852
5853
 
5853
- let enabled =
5854
- !("NO_COLOR" in process.env) &&
5855
- ("FORCE_COLOR" in process.env ||
5856
- process.platform === "win32" ||
5857
- (process.stdout != null &&
5858
- process.stdout.isTTY &&
5859
- process.env.TERM &&
5860
- process.env.TERM !== "dumb"));
5861
-
5862
- const raw = (open, close, searchRegex, replaceValue) => (s) =>
5863
- enabled
5864
- ? open +
5865
- (~(s += "").indexOf(close, 4) // skip opening \x1b[
5866
- ? s.replace(searchRegex, replaceValue)
5867
- : s) +
5868
- close
5869
- : s;
5870
-
5871
- const init = (open, close) => {
5872
- return raw(
5873
- `\x1b[${open}m`,
5874
- `\x1b[${close}m`,
5875
- new RegExp(`\\x1b\\[${close}m`, "g"),
5876
- `\x1b[${open}m`
5877
- )
5878
- };
5854
+ Object.defineProperty(colorette, '__esModule', { value: true });
5879
5855
 
5880
- colorette.options = Object.defineProperty({}, "enabled", {
5881
- get: () => enabled,
5882
- set: (value) => (enabled = value),
5883
- });
5856
+ var tty = require$$0$1;
5857
+
5858
+ function _interopNamespace(e) {
5859
+ if (e && e.__esModule) return e;
5860
+ var n = Object.create(null);
5861
+ if (e) {
5862
+ Object.keys(e).forEach(function (k) {
5863
+ if (k !== 'default') {
5864
+ var d = Object.getOwnPropertyDescriptor(e, k);
5865
+ Object.defineProperty(n, k, d.get ? d : {
5866
+ enumerable: true,
5867
+ get: function () { return e[k]; }
5868
+ });
5869
+ }
5870
+ });
5871
+ }
5872
+ n["default"] = e;
5873
+ return Object.freeze(n);
5874
+ }
5875
+
5876
+ var tty__namespace = /*#__PURE__*/_interopNamespace(tty);
5877
+
5878
+ const env = process.env || {};
5879
+ const argv$1 = process.argv || [];
5880
+
5881
+ const isDisabled = "NO_COLOR" in env || argv$1.includes("--no-color");
5882
+ const isForced = "FORCE_COLOR" in env || argv$1.includes("--color");
5883
+ const isWindows = process.platform === "win32";
5884
+
5885
+ const isCompatibleTerminal =
5886
+ tty__namespace && tty__namespace.isatty && tty__namespace.isatty(1) && env.TERM && env.TERM !== "dumb";
5887
+
5888
+ const isCI =
5889
+ "CI" in env &&
5890
+ ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
5891
+
5892
+ const isColorSupported =
5893
+ !isDisabled && (isForced || isWindows || isCompatibleTerminal || isCI);
5894
+
5895
+ const replaceClose = (
5896
+ index,
5897
+ string,
5898
+ close,
5899
+ replace,
5900
+ head = string.substring(0, index) + replace,
5901
+ tail = string.substring(index + close.length),
5902
+ next = tail.indexOf(close)
5903
+ ) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
5904
+
5905
+ const clearBleed = (index, string, open, close, replace) =>
5906
+ index < 0
5907
+ ? open + string + close
5908
+ : open + replaceClose(index, string, close, replace) + close;
5909
+
5910
+ const filterEmpty =
5911
+ (open, close, replace = open, at = open.length + 1) =>
5912
+ (string) =>
5913
+ string || !(string === "" || string === undefined)
5914
+ ? clearBleed(
5915
+ ("" + string).indexOf(close, at),
5916
+ string,
5917
+ open,
5918
+ close,
5919
+ replace
5920
+ )
5921
+ : "";
5922
+
5923
+ const init = (open, close, replace) =>
5924
+ filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
5925
+
5926
+ const colors = {
5927
+ reset: init(0, 0),
5928
+ bold: init(1, 22, "\x1b[22m\x1b[1m"),
5929
+ dim: init(2, 22, "\x1b[22m\x1b[2m"),
5930
+ italic: init(3, 23),
5931
+ underline: init(4, 24),
5932
+ inverse: init(7, 27),
5933
+ hidden: init(8, 28),
5934
+ strikethrough: init(9, 29),
5935
+ black: init(30, 39),
5936
+ red: init(31, 39),
5937
+ green: init(32, 39),
5938
+ yellow: init(33, 39),
5939
+ blue: init(34, 39),
5940
+ magenta: init(35, 39),
5941
+ cyan: init(36, 39),
5942
+ white: init(37, 39),
5943
+ gray: init(90, 39),
5944
+ bgBlack: init(40, 49),
5945
+ bgRed: init(41, 49),
5946
+ bgGreen: init(42, 49),
5947
+ bgYellow: init(43, 49),
5948
+ bgBlue: init(44, 49),
5949
+ bgMagenta: init(45, 49),
5950
+ bgCyan: init(46, 49),
5951
+ bgWhite: init(47, 49),
5952
+ blackBright: init(90, 39),
5953
+ redBright: init(91, 39),
5954
+ greenBright: init(92, 39),
5955
+ yellowBright: init(93, 39),
5956
+ blueBright: init(94, 39),
5957
+ magentaBright: init(95, 39),
5958
+ cyanBright: init(96, 39),
5959
+ whiteBright: init(97, 39),
5960
+ bgBlackBright: init(100, 49),
5961
+ bgRedBright: init(101, 49),
5962
+ bgGreenBright: init(102, 49),
5963
+ bgYellowBright: init(103, 49),
5964
+ bgBlueBright: init(104, 49),
5965
+ bgMagentaBright: init(105, 49),
5966
+ bgCyanBright: init(106, 49),
5967
+ bgWhiteBright: init(107, 49),
5968
+ };
5884
5969
 
5885
- colorette.reset = init(0, 0);
5886
- colorette.bold = raw("\x1b[1m", "\x1b[22m", /\x1b\[22m/g, "\x1b[22m\x1b[1m");
5887
- colorette.dim = raw("\x1b[2m", "\x1b[22m", /\x1b\[22m/g, "\x1b[22m\x1b[2m");
5888
- colorette.italic = init(3, 23);
5889
- colorette.underline = init(4, 24);
5890
- colorette.inverse = init(7, 27);
5891
- colorette.hidden = init(8, 28);
5892
- colorette.strikethrough = init(9, 29);
5893
- colorette.black = init(30, 39);
5894
- colorette.red = init(31, 39);
5895
- colorette.green = init(32, 39);
5896
- colorette.yellow = init(33, 39);
5897
- colorette.blue = init(34, 39);
5898
- colorette.magenta = init(35, 39);
5899
- colorette.cyan = init(36, 39);
5900
- colorette.white = init(37, 39);
5901
- colorette.gray = init(90, 39);
5902
- colorette.bgBlack = init(40, 49);
5903
- colorette.bgRed = init(41, 49);
5904
- colorette.bgGreen = init(42, 49);
5905
- colorette.bgYellow = init(43, 49);
5906
- colorette.bgBlue = init(44, 49);
5907
- colorette.bgMagenta = init(45, 49);
5908
- colorette.bgCyan = init(46, 49);
5909
- colorette.bgWhite = init(47, 49);
5910
- colorette.blackBright = init(90, 39);
5911
- colorette.redBright = init(91, 39);
5912
- colorette.greenBright = init(92, 39);
5913
- colorette.yellowBright = init(93, 39);
5914
- colorette.blueBright = init(94, 39);
5915
- colorette.magentaBright = init(95, 39);
5916
- colorette.cyanBright = init(96, 39);
5917
- colorette.whiteBright = init(97, 39);
5918
- colorette.bgBlackBright = init(100, 49);
5919
- colorette.bgRedBright = init(101, 49);
5920
- colorette.bgGreenBright = init(102, 49);
5921
- colorette.bgYellowBright = init(103, 49);
5922
- colorette.bgBlueBright = init(104, 49);
5923
- colorette.bgMagentaBright = init(105, 49);
5924
- colorette.bgCyanBright = init(106, 49);
5925
- colorette.bgWhiteBright = init(107, 49);
5970
+ const none = (any) => any;
5971
+
5972
+ const createColors = ({ useColor = isColorSupported } = {}) =>
5973
+ useColor
5974
+ ? colors
5975
+ : Object.keys(colors).reduce(
5976
+ (colors, key) => ({ ...colors, [key]: none }),
5977
+ {}
5978
+ );
5979
+
5980
+ const {
5981
+ reset,
5982
+ bold,
5983
+ dim,
5984
+ italic,
5985
+ underline,
5986
+ inverse,
5987
+ hidden,
5988
+ strikethrough,
5989
+ black,
5990
+ red,
5991
+ green,
5992
+ yellow,
5993
+ blue,
5994
+ magenta,
5995
+ cyan,
5996
+ white,
5997
+ gray,
5998
+ bgBlack,
5999
+ bgRed,
6000
+ bgGreen,
6001
+ bgYellow,
6002
+ bgBlue,
6003
+ bgMagenta,
6004
+ bgCyan,
6005
+ bgWhite,
6006
+ blackBright,
6007
+ redBright,
6008
+ greenBright,
6009
+ yellowBright,
6010
+ blueBright,
6011
+ magentaBright,
6012
+ cyanBright,
6013
+ whiteBright,
6014
+ bgBlackBright,
6015
+ bgRedBright,
6016
+ bgGreenBright,
6017
+ bgYellowBright,
6018
+ bgBlueBright,
6019
+ bgMagentaBright,
6020
+ bgCyanBright,
6021
+ bgWhiteBright,
6022
+ } = createColors();
6023
+
6024
+ colorette.bgBlack = bgBlack;
6025
+ colorette.bgBlackBright = bgBlackBright;
6026
+ colorette.bgBlue = bgBlue;
6027
+ colorette.bgBlueBright = bgBlueBright;
6028
+ colorette.bgCyan = bgCyan;
6029
+ colorette.bgCyanBright = bgCyanBright;
6030
+ colorette.bgGreen = bgGreen;
6031
+ colorette.bgGreenBright = bgGreenBright;
6032
+ colorette.bgMagenta = bgMagenta;
6033
+ colorette.bgMagentaBright = bgMagentaBright;
6034
+ colorette.bgRed = bgRed;
6035
+ colorette.bgRedBright = bgRedBright;
6036
+ colorette.bgWhite = bgWhite;
6037
+ colorette.bgWhiteBright = bgWhiteBright;
6038
+ colorette.bgYellow = bgYellow;
6039
+ colorette.bgYellowBright = bgYellowBright;
6040
+ colorette.black = black;
6041
+ colorette.blackBright = blackBright;
6042
+ colorette.blue = blue;
6043
+ colorette.blueBright = blueBright;
6044
+ colorette.bold = bold;
6045
+ colorette.createColors = createColors;
6046
+ var cyan_1 = colorette.cyan = cyan;
6047
+ colorette.cyanBright = cyanBright;
6048
+ colorette.dim = dim;
6049
+ colorette.gray = gray;
6050
+ colorette.green = green;
6051
+ colorette.greenBright = greenBright;
6052
+ colorette.hidden = hidden;
6053
+ colorette.inverse = inverse;
6054
+ colorette.isColorSupported = isColorSupported;
6055
+ colorette.italic = italic;
6056
+ colorette.magenta = magenta;
6057
+ colorette.magentaBright = magentaBright;
6058
+ colorette.red = red;
6059
+ colorette.redBright = redBright;
6060
+ colorette.reset = reset;
6061
+ colorette.strikethrough = strikethrough;
6062
+ colorette.underline = underline;
6063
+ colorette.white = white;
6064
+ colorette.whiteBright = whiteBright;
6065
+ colorette.yellow = yellow;
6066
+ colorette.yellowBright = yellowBright;
5926
6067
 
5927
6068
  /*
5928
6069
  How it works:
@@ -6230,6 +6371,8 @@ async function run() {
6230
6371
  } else {
6231
6372
  await createWorkspace();
6232
6373
  }
6374
+
6375
+ return;
6233
6376
  }
6234
6377
 
6235
6378
  switch (create) {
@@ -6261,6 +6404,7 @@ async function run() {
6261
6404
  async function createWorkspace(explicitName) {
6262
6405
  if (fs.existsSync('quilt.workspace.ts')) {
6263
6406
  console.log(`\nYou’re already in a Quilt workspace!`);
6407
+ console.log();
6264
6408
  console.log(`Run one of the following to add projects to your workspace:`);
6265
6409
  console.log(` pnpm create @quilted app # create a new app`);
6266
6410
  console.log(` pnpm create @quilted package # create a new package`);
@@ -6311,7 +6455,7 @@ async function createWorkspace(explicitName) {
6311
6455
  fs.mkdirSync(root);
6312
6456
  }
6313
6457
 
6314
- console.log(`\nCreating Quilt workspace in ${colorette.magenta(root)}...`);
6458
+ console.log(`\nCreating Quilt workspace in ${cyan_1(path.relative(cwd, root))}...`);
6315
6459
  const templateRoot = await templateDirectory('workspace');
6316
6460
  const template = createTemplateFileSystem(templateRoot, root);
6317
6461
 
@@ -6327,12 +6471,14 @@ async function createWorkspace(explicitName) {
6327
6471
  }
6328
6472
 
6329
6473
  console.log(`\nDone! Here’s what you’ll need to do next:\n`);
6474
+ console.log();
6330
6475
 
6331
6476
  if (root !== cwd) {
6332
6477
  console.log(` cd ${path.relative(cwd, root)}`);
6333
6478
  }
6334
6479
 
6335
6480
  console.log(` pnpm install # install dependencies`);
6481
+ console.log(` git init && git -am "Initial commit" # start your git history`);
6336
6482
  console.log(` pnpm create @quilted app # create an app in your workspace, or`);
6337
6483
  console.log(` pnpm create @quilted package # create a package in your workspace`);
6338
6484
  console.log();
@@ -6340,7 +6486,7 @@ async function createWorkspace(explicitName) {
6340
6486
 
6341
6487
  async function createProject() {
6342
6488
  const result = await prompts([{
6343
- type: 'list',
6489
+ type: 'select',
6344
6490
  name: 'type',
6345
6491
  message: 'What kind of project would you like to create?',
6346
6492
  choices: [{
@@ -6368,8 +6514,10 @@ async function createProject() {
6368
6514
  }
6369
6515
 
6370
6516
  async function createPackage(explicitName) {
6371
- let result;
6517
+ let name;
6518
+ let scope;
6372
6519
  let targetDirectory;
6520
+ let result;
6373
6521
 
6374
6522
  try {
6375
6523
  result = await prompts([{
@@ -6378,7 +6526,9 @@ async function createPackage(explicitName) {
6378
6526
  message: 'What would you like to name this package?',
6379
6527
  initial: toValidPackageName(explicitName ?? ''),
6380
6528
  onState: state => {
6381
- targetDirectory = path.join('packages', toValidPackageName(state.value));
6529
+ name = toValidPackageName(state.value);
6530
+ scope = name.match(/^@[^/]+/)?.[0] ?? undefined;
6531
+ targetDirectory = path.join('packages', scope ? name.replace(`${scope}/`, '') : name);
6382
6532
  }
6383
6533
  }, {
6384
6534
  type: () => !fs.existsSync(targetDirectory) || isEmpty(targetDirectory) ? null : 'confirm',
@@ -6400,7 +6550,6 @@ async function createPackage(explicitName) {
6400
6550
  }
6401
6551
 
6402
6552
  const {
6403
- name,
6404
6553
  overwrite
6405
6554
  } = result;
6406
6555
  const root = path.join(cwd, targetDirectory);
@@ -6411,14 +6560,19 @@ async function createPackage(explicitName) {
6411
6560
  fs.mkdirSync(root);
6412
6561
  }
6413
6562
 
6414
- console.log(`\nCreating ${colorette.magenta(toValidPackageName(name))} package in ${colorette.magenta(root)}...`);
6563
+ console.log(`\nCreating ${cyan_1(name)} package in ${cyan_1(path.relative(cwd, root))}...`);
6415
6564
  const templateRoot = await templateDirectory('package');
6416
6565
  const template = createTemplateFileSystem(templateRoot, root);
6417
6566
 
6418
6567
  for (const file of template.files()) {
6419
6568
  if (file === 'package.json') {
6420
6569
  const packageJson = JSON.parse(template.read(file));
6421
- packageJson.name = toValidPackageName(name);
6570
+ packageJson.name = name;
6571
+
6572
+ if (scope) {
6573
+ packageJson.publishConfig[`${scope}:registry`] = 'https://registry.npmjs.org';
6574
+ }
6575
+
6422
6576
  template.write(file, JSON.stringify(packageJson, null, 2) + EOL);
6423
6577
  continue;
6424
6578
  }
@@ -6426,14 +6580,15 @@ async function createPackage(explicitName) {
6426
6580
  template.copy(file);
6427
6581
  }
6428
6582
 
6429
- console.log(`\nDone! Your new package has been created.\n`);
6583
+ console.log(`\nDone! Your new package has been created.`);
6430
6584
  console.log(`Get started by adding source code in the \`source\` directory.`);
6585
+ console.log(`Make sure to edit the \`description\` and \`repository\` sections of your \`package.json\` before publishing.`);
6431
6586
  console.log(`Have fun!`);
6432
6587
  console.log();
6433
6588
  }
6434
6589
 
6435
6590
  async function createApp() {
6436
- const root = path.join('cwd', 'app');
6591
+ const root = path.join(cwd, 'app');
6437
6592
 
6438
6593
  if (fs.existsSync(root)) {
6439
6594
  const {
@@ -6449,7 +6604,7 @@ async function createApp() {
6449
6604
  fs.mkdirSync(root);
6450
6605
  }
6451
6606
 
6452
- console.log(`\nCreating app in ${colorette.magenta(root)}...`);
6607
+ console.log(`\nCreating app in ${cyan_1(path.relative(cwd, root))}...`);
6453
6608
  const templateRoot = await templateDirectory('app');
6454
6609
  const template = createTemplateFileSystem(templateRoot, root);
6455
6610
 
@@ -6464,7 +6619,7 @@ async function createApp() {
6464
6619
  template.copy(file);
6465
6620
  }
6466
6621
 
6467
- console.log(`\nDone! Your new app has been created.\n`);
6622
+ console.log(`\nDone! Your new app has been created.`);
6468
6623
  console.log(`Get started by:`);
6469
6624
  console.log(` * running \`pnpm develop\` to start the development server`);
6470
6625
  console.log(` * editing code in the \`app\` directory`);
@@ -6506,7 +6661,7 @@ async function templateDirectory(name) {
6506
6661
  }
6507
6662
 
6508
6663
  function toValidPackageName(projectName) {
6509
- return projectName.trim().toLowerCase().replace(/\s+/g, '-').replace(/^[._]/, '').replace(/[^a-z0-9-~@]+/g, '-');
6664
+ return projectName.trim().toLowerCase().replace(/\s+/g, '-').replace(/^[._]/, '').replace(/[^a-z0-9-~@/]+/g, '-');
6510
6665
  }
6511
6666
 
6512
6667
  function copy(source, destination) {