@quilted/create 0.1.0 → 0.1.3

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`);
@@ -6308,10 +6452,12 @@ async function createWorkspace(explicitName) {
6308
6452
  if (overwrite) {
6309
6453
  emptyDirectory(root);
6310
6454
  } else if (!fs.existsSync(root)) {
6311
- fs.mkdirSync(root);
6455
+ fs.mkdirSync(root, {
6456
+ recursive: true
6457
+ });
6312
6458
  }
6313
6459
 
6314
- console.log(`\nCreating Quilt workspace in ${colorette.magenta(root)}...`);
6460
+ console.log(`\nCreating Quilt workspace in ${cyan_1(path.relative(cwd, root))}...`);
6315
6461
  const templateRoot = await templateDirectory('workspace');
6316
6462
  const template = createTemplateFileSystem(templateRoot, root);
6317
6463
 
@@ -6327,12 +6473,14 @@ async function createWorkspace(explicitName) {
6327
6473
  }
6328
6474
 
6329
6475
  console.log(`\nDone! Here’s what you’ll need to do next:\n`);
6476
+ console.log();
6330
6477
 
6331
6478
  if (root !== cwd) {
6332
6479
  console.log(` cd ${path.relative(cwd, root)}`);
6333
6480
  }
6334
6481
 
6335
6482
  console.log(` pnpm install # install dependencies`);
6483
+ console.log(` git init && git add --all && git commit --message "Initial commit" # start your git history`);
6336
6484
  console.log(` pnpm create @quilted app # create an app in your workspace, or`);
6337
6485
  console.log(` pnpm create @quilted package # create a package in your workspace`);
6338
6486
  console.log();
@@ -6340,7 +6488,7 @@ async function createWorkspace(explicitName) {
6340
6488
 
6341
6489
  async function createProject() {
6342
6490
  const result = await prompts([{
6343
- type: 'list',
6491
+ type: 'select',
6344
6492
  name: 'type',
6345
6493
  message: 'What kind of project would you like to create?',
6346
6494
  choices: [{
@@ -6368,8 +6516,10 @@ async function createProject() {
6368
6516
  }
6369
6517
 
6370
6518
  async function createPackage(explicitName) {
6371
- let result;
6519
+ let name;
6520
+ let scope;
6372
6521
  let targetDirectory;
6522
+ let result;
6373
6523
 
6374
6524
  try {
6375
6525
  result = await prompts([{
@@ -6378,7 +6528,9 @@ async function createPackage(explicitName) {
6378
6528
  message: 'What would you like to name this package?',
6379
6529
  initial: toValidPackageName(explicitName ?? ''),
6380
6530
  onState: state => {
6381
- targetDirectory = path.join('packages', toValidPackageName(state.value));
6531
+ name = toValidPackageName(state.value);
6532
+ scope = name.match(/^@[^/]+/)?.[0] ?? undefined;
6533
+ targetDirectory = path.join('packages', scope ? name.replace(`${scope}/`, '') : name);
6382
6534
  }
6383
6535
  }, {
6384
6536
  type: () => !fs.existsSync(targetDirectory) || isEmpty(targetDirectory) ? null : 'confirm',
@@ -6400,7 +6552,6 @@ async function createPackage(explicitName) {
6400
6552
  }
6401
6553
 
6402
6554
  const {
6403
- name,
6404
6555
  overwrite
6405
6556
  } = result;
6406
6557
  const root = path.join(cwd, targetDirectory);
@@ -6408,17 +6559,24 @@ async function createPackage(explicitName) {
6408
6559
  if (overwrite) {
6409
6560
  emptyDirectory(root);
6410
6561
  } else if (!fs.existsSync(root)) {
6411
- fs.mkdirSync(root);
6562
+ fs.mkdirSync(root, {
6563
+ recursive: true
6564
+ });
6412
6565
  }
6413
6566
 
6414
- console.log(`\nCreating ${colorette.magenta(toValidPackageName(name))} package in ${colorette.magenta(root)}...`);
6567
+ console.log(`\nCreating ${cyan_1(name)} package in ${cyan_1(path.relative(cwd, root))}...`);
6415
6568
  const templateRoot = await templateDirectory('package');
6416
6569
  const template = createTemplateFileSystem(templateRoot, root);
6417
6570
 
6418
6571
  for (const file of template.files()) {
6419
6572
  if (file === 'package.json') {
6420
6573
  const packageJson = JSON.parse(template.read(file));
6421
- packageJson.name = toValidPackageName(name);
6574
+ packageJson.name = name;
6575
+
6576
+ if (scope) {
6577
+ packageJson.publishConfig[`${scope}:registry`] = 'https://registry.npmjs.org';
6578
+ }
6579
+
6422
6580
  template.write(file, JSON.stringify(packageJson, null, 2) + EOL);
6423
6581
  continue;
6424
6582
  }
@@ -6426,14 +6584,15 @@ async function createPackage(explicitName) {
6426
6584
  template.copy(file);
6427
6585
  }
6428
6586
 
6429
- console.log(`\nDone! Your new package has been created.\n`);
6587
+ console.log(`\nDone! Your new package has been created.`);
6430
6588
  console.log(`Get started by adding source code in the \`source\` directory.`);
6589
+ console.log(`Make sure to edit the \`description\` and \`repository\` sections of your \`package.json\` before publishing.`);
6431
6590
  console.log(`Have fun!`);
6432
6591
  console.log();
6433
6592
  }
6434
6593
 
6435
6594
  async function createApp() {
6436
- const root = path.join('cwd', 'app');
6595
+ const root = path.join(cwd, 'app');
6437
6596
 
6438
6597
  if (fs.existsSync(root)) {
6439
6598
  const {
@@ -6446,10 +6605,12 @@ async function createApp() {
6446
6605
  if (!overwrite) return;
6447
6606
  emptyDirectory(root);
6448
6607
  } else if (!fs.existsSync(root)) {
6449
- fs.mkdirSync(root);
6608
+ fs.mkdirSync(root, {
6609
+ recursive: true
6610
+ });
6450
6611
  }
6451
6612
 
6452
- console.log(`\nCreating app in ${colorette.magenta(root)}...`);
6613
+ console.log(`\nCreating app in ${cyan_1(path.relative(cwd, root))}...`);
6453
6614
  const templateRoot = await templateDirectory('app');
6454
6615
  const template = createTemplateFileSystem(templateRoot, root);
6455
6616
 
@@ -6464,7 +6625,7 @@ async function createApp() {
6464
6625
  template.copy(file);
6465
6626
  }
6466
6627
 
6467
- console.log(`\nDone! Your new app has been created.\n`);
6628
+ console.log(`\nDone! Your new app has been created.`);
6468
6629
  console.log(`Get started by:`);
6469
6630
  console.log(` * running \`pnpm develop\` to start the development server`);
6470
6631
  console.log(` * editing code in the \`app\` directory`);
@@ -6506,7 +6667,7 @@ async function templateDirectory(name) {
6506
6667
  }
6507
6668
 
6508
6669
  function toValidPackageName(projectName) {
6509
- return projectName.trim().toLowerCase().replace(/\s+/g, '-').replace(/^[._]/, '').replace(/[^a-z0-9-~@]+/g, '-');
6670
+ return projectName.trim().toLowerCase().replace(/\s+/g, '-').replace(/^[._]/, '').replace(/[^a-z0-9-~@/]+/g, '-');
6510
6671
  }
6511
6672
 
6512
6673
  function copy(source, destination) {