@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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @quilted/create
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`dea9f232`](https://github.com/lemonmade/quilt/commit/dea9f232e760f783114b9b5e9855b2b995b2e90e) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix @quilted/create workspace
@@ -6,6 +6,7 @@ var os = require('os');
6
6
  var url = require('url');
7
7
  var require$$0 = require('readline');
8
8
  var require$$2 = require('events');
9
+ var require$$0$1 = require('tty');
9
10
  var path = require('node:path');
10
11
  var node_url = require('node:url');
11
12
  var process$1 = require('node:process');
@@ -35,6 +36,7 @@ var fs__namespace = /*#__PURE__*/_interopNamespace(fs$1);
35
36
  var path__namespace = /*#__PURE__*/_interopNamespace(path$1);
36
37
  var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
37
38
  var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
39
+ var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
38
40
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
39
41
  var process__default = /*#__PURE__*/_interopDefaultLegacy(process$1);
40
42
 
@@ -5879,79 +5881,219 @@ var arg_1 = arg;
5879
5881
 
5880
5882
  var colorette = {};
5881
5883
 
5882
- let enabled =
5883
- !("NO_COLOR" in process.env) &&
5884
- ("FORCE_COLOR" in process.env ||
5885
- process.platform === "win32" ||
5886
- (process.stdout != null &&
5887
- process.stdout.isTTY &&
5888
- process.env.TERM &&
5889
- process.env.TERM !== "dumb"));
5890
-
5891
- const raw = (open, close, searchRegex, replaceValue) => (s) =>
5892
- enabled
5893
- ? open +
5894
- (~(s += "").indexOf(close, 4) // skip opening \x1b[
5895
- ? s.replace(searchRegex, replaceValue)
5896
- : s) +
5897
- close
5898
- : s;
5899
-
5900
- const init = (open, close) => {
5901
- return raw(
5902
- `\x1b[${open}m`,
5903
- `\x1b[${close}m`,
5904
- new RegExp(`\\x1b\\[${close}m`, "g"),
5905
- `\x1b[${open}m`
5906
- )
5907
- };
5884
+ Object.defineProperty(colorette, '__esModule', { value: true });
5908
5885
 
5909
- colorette.options = Object.defineProperty({}, "enabled", {
5910
- get: () => enabled,
5911
- set: (value) => (enabled = value),
5912
- });
5886
+ var tty = require$$0__default$1["default"];
5887
+
5888
+ function _interopNamespace$1(e) {
5889
+ if (e && e.__esModule) return e;
5890
+ var n = Object.create(null);
5891
+ if (e) {
5892
+ Object.keys(e).forEach(function (k) {
5893
+ if (k !== 'default') {
5894
+ var d = Object.getOwnPropertyDescriptor(e, k);
5895
+ Object.defineProperty(n, k, d.get ? d : {
5896
+ enumerable: true,
5897
+ get: function () { return e[k]; }
5898
+ });
5899
+ }
5900
+ });
5901
+ }
5902
+ n["default"] = e;
5903
+ return Object.freeze(n);
5904
+ }
5905
+
5906
+ var tty__namespace = /*#__PURE__*/_interopNamespace$1(tty);
5907
+
5908
+ const env = process.env || {};
5909
+ const argv$1 = process.argv || [];
5910
+
5911
+ const isDisabled = "NO_COLOR" in env || argv$1.includes("--no-color");
5912
+ const isForced = "FORCE_COLOR" in env || argv$1.includes("--color");
5913
+ const isWindows = process.platform === "win32";
5914
+
5915
+ const isCompatibleTerminal =
5916
+ tty__namespace && tty__namespace.isatty && tty__namespace.isatty(1) && env.TERM && env.TERM !== "dumb";
5917
+
5918
+ const isCI =
5919
+ "CI" in env &&
5920
+ ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
5921
+
5922
+ const isColorSupported =
5923
+ !isDisabled && (isForced || isWindows || isCompatibleTerminal || isCI);
5924
+
5925
+ const replaceClose = (
5926
+ index,
5927
+ string,
5928
+ close,
5929
+ replace,
5930
+ head = string.substring(0, index) + replace,
5931
+ tail = string.substring(index + close.length),
5932
+ next = tail.indexOf(close)
5933
+ ) => head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
5934
+
5935
+ const clearBleed = (index, string, open, close, replace) =>
5936
+ index < 0
5937
+ ? open + string + close
5938
+ : open + replaceClose(index, string, close, replace) + close;
5939
+
5940
+ const filterEmpty =
5941
+ (open, close, replace = open, at = open.length + 1) =>
5942
+ (string) =>
5943
+ string || !(string === "" || string === undefined)
5944
+ ? clearBleed(
5945
+ ("" + string).indexOf(close, at),
5946
+ string,
5947
+ open,
5948
+ close,
5949
+ replace
5950
+ )
5951
+ : "";
5952
+
5953
+ const init = (open, close, replace) =>
5954
+ filterEmpty(`\x1b[${open}m`, `\x1b[${close}m`, replace);
5955
+
5956
+ const colors = {
5957
+ reset: init(0, 0),
5958
+ bold: init(1, 22, "\x1b[22m\x1b[1m"),
5959
+ dim: init(2, 22, "\x1b[22m\x1b[2m"),
5960
+ italic: init(3, 23),
5961
+ underline: init(4, 24),
5962
+ inverse: init(7, 27),
5963
+ hidden: init(8, 28),
5964
+ strikethrough: init(9, 29),
5965
+ black: init(30, 39),
5966
+ red: init(31, 39),
5967
+ green: init(32, 39),
5968
+ yellow: init(33, 39),
5969
+ blue: init(34, 39),
5970
+ magenta: init(35, 39),
5971
+ cyan: init(36, 39),
5972
+ white: init(37, 39),
5973
+ gray: init(90, 39),
5974
+ bgBlack: init(40, 49),
5975
+ bgRed: init(41, 49),
5976
+ bgGreen: init(42, 49),
5977
+ bgYellow: init(43, 49),
5978
+ bgBlue: init(44, 49),
5979
+ bgMagenta: init(45, 49),
5980
+ bgCyan: init(46, 49),
5981
+ bgWhite: init(47, 49),
5982
+ blackBright: init(90, 39),
5983
+ redBright: init(91, 39),
5984
+ greenBright: init(92, 39),
5985
+ yellowBright: init(93, 39),
5986
+ blueBright: init(94, 39),
5987
+ magentaBright: init(95, 39),
5988
+ cyanBright: init(96, 39),
5989
+ whiteBright: init(97, 39),
5990
+ bgBlackBright: init(100, 49),
5991
+ bgRedBright: init(101, 49),
5992
+ bgGreenBright: init(102, 49),
5993
+ bgYellowBright: init(103, 49),
5994
+ bgBlueBright: init(104, 49),
5995
+ bgMagentaBright: init(105, 49),
5996
+ bgCyanBright: init(106, 49),
5997
+ bgWhiteBright: init(107, 49),
5998
+ };
5913
5999
 
5914
- colorette.reset = init(0, 0);
5915
- colorette.bold = raw("\x1b[1m", "\x1b[22m", /\x1b\[22m/g, "\x1b[22m\x1b[1m");
5916
- colorette.dim = raw("\x1b[2m", "\x1b[22m", /\x1b\[22m/g, "\x1b[22m\x1b[2m");
5917
- colorette.italic = init(3, 23);
5918
- colorette.underline = init(4, 24);
5919
- colorette.inverse = init(7, 27);
5920
- colorette.hidden = init(8, 28);
5921
- colorette.strikethrough = init(9, 29);
5922
- colorette.black = init(30, 39);
5923
- colorette.red = init(31, 39);
5924
- colorette.green = init(32, 39);
5925
- colorette.yellow = init(33, 39);
5926
- colorette.blue = init(34, 39);
5927
- colorette.magenta = init(35, 39);
5928
- colorette.cyan = init(36, 39);
5929
- colorette.white = init(37, 39);
5930
- colorette.gray = init(90, 39);
5931
- colorette.bgBlack = init(40, 49);
5932
- colorette.bgRed = init(41, 49);
5933
- colorette.bgGreen = init(42, 49);
5934
- colorette.bgYellow = init(43, 49);
5935
- colorette.bgBlue = init(44, 49);
5936
- colorette.bgMagenta = init(45, 49);
5937
- colorette.bgCyan = init(46, 49);
5938
- colorette.bgWhite = init(47, 49);
5939
- colorette.blackBright = init(90, 39);
5940
- colorette.redBright = init(91, 39);
5941
- colorette.greenBright = init(92, 39);
5942
- colorette.yellowBright = init(93, 39);
5943
- colorette.blueBright = init(94, 39);
5944
- colorette.magentaBright = init(95, 39);
5945
- colorette.cyanBright = init(96, 39);
5946
- colorette.whiteBright = init(97, 39);
5947
- colorette.bgBlackBright = init(100, 49);
5948
- colorette.bgRedBright = init(101, 49);
5949
- colorette.bgGreenBright = init(102, 49);
5950
- colorette.bgYellowBright = init(103, 49);
5951
- colorette.bgBlueBright = init(104, 49);
5952
- colorette.bgMagentaBright = init(105, 49);
5953
- colorette.bgCyanBright = init(106, 49);
5954
- colorette.bgWhiteBright = init(107, 49);
6000
+ const none = (any) => any;
6001
+
6002
+ const createColors = ({ useColor = isColorSupported } = {}) =>
6003
+ useColor
6004
+ ? colors
6005
+ : Object.keys(colors).reduce(
6006
+ (colors, key) => ({ ...colors, [key]: none }),
6007
+ {}
6008
+ );
6009
+
6010
+ const {
6011
+ reset,
6012
+ bold,
6013
+ dim,
6014
+ italic,
6015
+ underline,
6016
+ inverse,
6017
+ hidden,
6018
+ strikethrough,
6019
+ black,
6020
+ red,
6021
+ green,
6022
+ yellow,
6023
+ blue,
6024
+ magenta,
6025
+ cyan,
6026
+ white,
6027
+ gray,
6028
+ bgBlack,
6029
+ bgRed,
6030
+ bgGreen,
6031
+ bgYellow,
6032
+ bgBlue,
6033
+ bgMagenta,
6034
+ bgCyan,
6035
+ bgWhite,
6036
+ blackBright,
6037
+ redBright,
6038
+ greenBright,
6039
+ yellowBright,
6040
+ blueBright,
6041
+ magentaBright,
6042
+ cyanBright,
6043
+ whiteBright,
6044
+ bgBlackBright,
6045
+ bgRedBright,
6046
+ bgGreenBright,
6047
+ bgYellowBright,
6048
+ bgBlueBright,
6049
+ bgMagentaBright,
6050
+ bgCyanBright,
6051
+ bgWhiteBright,
6052
+ } = createColors();
6053
+
6054
+ colorette.bgBlack = bgBlack;
6055
+ colorette.bgBlackBright = bgBlackBright;
6056
+ colorette.bgBlue = bgBlue;
6057
+ colorette.bgBlueBright = bgBlueBright;
6058
+ colorette.bgCyan = bgCyan;
6059
+ colorette.bgCyanBright = bgCyanBright;
6060
+ colorette.bgGreen = bgGreen;
6061
+ colorette.bgGreenBright = bgGreenBright;
6062
+ colorette.bgMagenta = bgMagenta;
6063
+ colorette.bgMagentaBright = bgMagentaBright;
6064
+ colorette.bgRed = bgRed;
6065
+ colorette.bgRedBright = bgRedBright;
6066
+ colorette.bgWhite = bgWhite;
6067
+ colorette.bgWhiteBright = bgWhiteBright;
6068
+ colorette.bgYellow = bgYellow;
6069
+ colorette.bgYellowBright = bgYellowBright;
6070
+ colorette.black = black;
6071
+ colorette.blackBright = blackBright;
6072
+ colorette.blue = blue;
6073
+ colorette.blueBright = blueBright;
6074
+ colorette.bold = bold;
6075
+ colorette.createColors = createColors;
6076
+ var cyan_1 = colorette.cyan = cyan;
6077
+ colorette.cyanBright = cyanBright;
6078
+ colorette.dim = dim;
6079
+ colorette.gray = gray;
6080
+ colorette.green = green;
6081
+ colorette.greenBright = greenBright;
6082
+ colorette.hidden = hidden;
6083
+ colorette.inverse = inverse;
6084
+ colorette.isColorSupported = isColorSupported;
6085
+ colorette.italic = italic;
6086
+ colorette.magenta = magenta;
6087
+ colorette.magentaBright = magentaBright;
6088
+ colorette.red = red;
6089
+ colorette.redBright = redBright;
6090
+ colorette.reset = reset;
6091
+ colorette.strikethrough = strikethrough;
6092
+ colorette.underline = underline;
6093
+ colorette.white = white;
6094
+ colorette.whiteBright = whiteBright;
6095
+ colorette.yellow = yellow;
6096
+ colorette.yellowBright = yellowBright;
5955
6097
 
5956
6098
  /*
5957
6099
  How it works:
@@ -6259,6 +6401,8 @@ async function run() {
6259
6401
  } else {
6260
6402
  await createWorkspace();
6261
6403
  }
6404
+
6405
+ return;
6262
6406
  }
6263
6407
 
6264
6408
  switch (create) {
@@ -6290,6 +6434,7 @@ async function run() {
6290
6434
  async function createWorkspace(explicitName) {
6291
6435
  if (fs__namespace.existsSync('quilt.workspace.ts')) {
6292
6436
  console.log(`\nYou’re already in a Quilt workspace!`);
6437
+ console.log();
6293
6438
  console.log(`Run one of the following to add projects to your workspace:`);
6294
6439
  console.log(` pnpm create @quilted app # create a new app`);
6295
6440
  console.log(` pnpm create @quilted package # create a new package`);
@@ -6340,7 +6485,7 @@ async function createWorkspace(explicitName) {
6340
6485
  fs__namespace.mkdirSync(root);
6341
6486
  }
6342
6487
 
6343
- console.log(`\nCreating Quilt workspace in ${colorette.magenta(root)}...`);
6488
+ console.log(`\nCreating Quilt workspace in ${cyan_1(path__namespace.relative(cwd, root))}...`);
6344
6489
  const templateRoot = await templateDirectory('workspace');
6345
6490
  const template = createTemplateFileSystem(templateRoot, root);
6346
6491
 
@@ -6356,12 +6501,14 @@ async function createWorkspace(explicitName) {
6356
6501
  }
6357
6502
 
6358
6503
  console.log(`\nDone! Here’s what you’ll need to do next:\n`);
6504
+ console.log();
6359
6505
 
6360
6506
  if (root !== cwd) {
6361
6507
  console.log(` cd ${path__namespace.relative(cwd, root)}`);
6362
6508
  }
6363
6509
 
6364
6510
  console.log(` pnpm install # install dependencies`);
6511
+ console.log(` git init && git -am "Initial commit" # start your git history`);
6365
6512
  console.log(` pnpm create @quilted app # create an app in your workspace, or`);
6366
6513
  console.log(` pnpm create @quilted package # create a package in your workspace`);
6367
6514
  console.log();
@@ -6369,7 +6516,7 @@ async function createWorkspace(explicitName) {
6369
6516
 
6370
6517
  async function createProject() {
6371
6518
  const result = await prompts([{
6372
- type: 'list',
6519
+ type: 'select',
6373
6520
  name: 'type',
6374
6521
  message: 'What kind of project would you like to create?',
6375
6522
  choices: [{
@@ -6397,8 +6544,10 @@ async function createProject() {
6397
6544
  }
6398
6545
 
6399
6546
  async function createPackage(explicitName) {
6400
- let result;
6547
+ let name;
6548
+ let scope;
6401
6549
  let targetDirectory;
6550
+ let result;
6402
6551
 
6403
6552
  try {
6404
6553
  result = await prompts([{
@@ -6407,7 +6556,9 @@ async function createPackage(explicitName) {
6407
6556
  message: 'What would you like to name this package?',
6408
6557
  initial: toValidPackageName(explicitName ?? ''),
6409
6558
  onState: state => {
6410
- targetDirectory = path__namespace.join('packages', toValidPackageName(state.value));
6559
+ name = toValidPackageName(state.value);
6560
+ scope = name.match(/^@[^/]+/)?.[0] ?? undefined;
6561
+ targetDirectory = path__namespace.join('packages', scope ? name.replace(`${scope}/`, '') : name);
6411
6562
  }
6412
6563
  }, {
6413
6564
  type: () => !fs__namespace.existsSync(targetDirectory) || isEmpty(targetDirectory) ? null : 'confirm',
@@ -6429,7 +6580,6 @@ async function createPackage(explicitName) {
6429
6580
  }
6430
6581
 
6431
6582
  const {
6432
- name,
6433
6583
  overwrite
6434
6584
  } = result;
6435
6585
  const root = path__namespace.join(cwd, targetDirectory);
@@ -6440,14 +6590,19 @@ async function createPackage(explicitName) {
6440
6590
  fs__namespace.mkdirSync(root);
6441
6591
  }
6442
6592
 
6443
- console.log(`\nCreating ${colorette.magenta(toValidPackageName(name))} package in ${colorette.magenta(root)}...`);
6593
+ console.log(`\nCreating ${cyan_1(name)} package in ${cyan_1(path__namespace.relative(cwd, root))}...`);
6444
6594
  const templateRoot = await templateDirectory('package');
6445
6595
  const template = createTemplateFileSystem(templateRoot, root);
6446
6596
 
6447
6597
  for (const file of template.files()) {
6448
6598
  if (file === 'package.json') {
6449
6599
  const packageJson = JSON.parse(template.read(file));
6450
- packageJson.name = toValidPackageName(name);
6600
+ packageJson.name = name;
6601
+
6602
+ if (scope) {
6603
+ packageJson.publishConfig[`${scope}:registry`] = 'https://registry.npmjs.org';
6604
+ }
6605
+
6451
6606
  template.write(file, JSON.stringify(packageJson, null, 2) + os.EOL);
6452
6607
  continue;
6453
6608
  }
@@ -6455,14 +6610,15 @@ async function createPackage(explicitName) {
6455
6610
  template.copy(file);
6456
6611
  }
6457
6612
 
6458
- console.log(`\nDone! Your new package has been created.\n`);
6613
+ console.log(`\nDone! Your new package has been created.`);
6459
6614
  console.log(`Get started by adding source code in the \`source\` directory.`);
6615
+ console.log(`Make sure to edit the \`description\` and \`repository\` sections of your \`package.json\` before publishing.`);
6460
6616
  console.log(`Have fun!`);
6461
6617
  console.log();
6462
6618
  }
6463
6619
 
6464
6620
  async function createApp() {
6465
- const root = path__namespace.join('cwd', 'app');
6621
+ const root = path__namespace.join(cwd, 'app');
6466
6622
 
6467
6623
  if (fs__namespace.existsSync(root)) {
6468
6624
  const {
@@ -6478,7 +6634,7 @@ async function createApp() {
6478
6634
  fs__namespace.mkdirSync(root);
6479
6635
  }
6480
6636
 
6481
- console.log(`\nCreating app in ${colorette.magenta(root)}...`);
6637
+ console.log(`\nCreating app in ${cyan_1(path__namespace.relative(cwd, root))}...`);
6482
6638
  const templateRoot = await templateDirectory('app');
6483
6639
  const template = createTemplateFileSystem(templateRoot, root);
6484
6640
 
@@ -6493,7 +6649,7 @@ async function createApp() {
6493
6649
  template.copy(file);
6494
6650
  }
6495
6651
 
6496
- console.log(`\nDone! Your new app has been created.\n`);
6652
+ console.log(`\nDone! Your new app has been created.`);
6497
6653
  console.log(`Get started by:`);
6498
6654
  console.log(` * running \`pnpm develop\` to start the development server`);
6499
6655
  console.log(` * editing code in the \`app\` directory`);
@@ -6535,7 +6691,7 @@ async function templateDirectory(name) {
6535
6691
  }
6536
6692
 
6537
6693
  function toValidPackageName(projectName) {
6538
- return projectName.trim().toLowerCase().replace(/\s+/g, '-').replace(/^[._]/, '').replace(/[^a-z0-9-~@]+/g, '-');
6694
+ return projectName.trim().toLowerCase().replace(/\s+/g, '-').replace(/^[._]/, '').replace(/[^a-z0-9-~@/]+/g, '-');
6539
6695
  }
6540
6696
 
6541
6697
  function copy(source, destination) {