@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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ # @quilted/create
2
+
3
+ ## 0.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`c49aa7dc`](https://github.com/lemonmade/quilt/commit/c49aa7dc3cf8e3f4b82a529cd74967a2155d7746) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix workspace pnpm template files
8
+
9
+ ## 0.1.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`e4e7cc23`](https://github.com/lemonmade/quilt/commit/e4e7cc23e50a55831c24e9b8f5df4e9dd6d6c36b) Thanks [@lemonmade](https://github.com/lemonmade)! - Fix create package to recursively create directories
14
+
15
+ ## 0.1.1
16
+
17
+ ### Patch Changes
18
+
19
+ - [`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`);
@@ -6337,10 +6482,12 @@ async function createWorkspace(explicitName) {
6337
6482
  if (overwrite) {
6338
6483
  emptyDirectory(root);
6339
6484
  } else if (!fs__namespace.existsSync(root)) {
6340
- fs__namespace.mkdirSync(root);
6485
+ fs__namespace.mkdirSync(root, {
6486
+ recursive: true
6487
+ });
6341
6488
  }
6342
6489
 
6343
- console.log(`\nCreating Quilt workspace in ${colorette.magenta(root)}...`);
6490
+ console.log(`\nCreating Quilt workspace in ${cyan_1(path__namespace.relative(cwd, root))}...`);
6344
6491
  const templateRoot = await templateDirectory('workspace');
6345
6492
  const template = createTemplateFileSystem(templateRoot, root);
6346
6493
 
@@ -6356,12 +6503,14 @@ async function createWorkspace(explicitName) {
6356
6503
  }
6357
6504
 
6358
6505
  console.log(`\nDone! Here’s what you’ll need to do next:\n`);
6506
+ console.log();
6359
6507
 
6360
6508
  if (root !== cwd) {
6361
6509
  console.log(` cd ${path__namespace.relative(cwd, root)}`);
6362
6510
  }
6363
6511
 
6364
6512
  console.log(` pnpm install # install dependencies`);
6513
+ console.log(` git init && git add --all && git commit --message "Initial commit" # start your git history`);
6365
6514
  console.log(` pnpm create @quilted app # create an app in your workspace, or`);
6366
6515
  console.log(` pnpm create @quilted package # create a package in your workspace`);
6367
6516
  console.log();
@@ -6369,7 +6518,7 @@ async function createWorkspace(explicitName) {
6369
6518
 
6370
6519
  async function createProject() {
6371
6520
  const result = await prompts([{
6372
- type: 'list',
6521
+ type: 'select',
6373
6522
  name: 'type',
6374
6523
  message: 'What kind of project would you like to create?',
6375
6524
  choices: [{
@@ -6397,8 +6546,10 @@ async function createProject() {
6397
6546
  }
6398
6547
 
6399
6548
  async function createPackage(explicitName) {
6400
- let result;
6549
+ let name;
6550
+ let scope;
6401
6551
  let targetDirectory;
6552
+ let result;
6402
6553
 
6403
6554
  try {
6404
6555
  result = await prompts([{
@@ -6407,7 +6558,9 @@ async function createPackage(explicitName) {
6407
6558
  message: 'What would you like to name this package?',
6408
6559
  initial: toValidPackageName(explicitName ?? ''),
6409
6560
  onState: state => {
6410
- targetDirectory = path__namespace.join('packages', toValidPackageName(state.value));
6561
+ name = toValidPackageName(state.value);
6562
+ scope = name.match(/^@[^/]+/)?.[0] ?? undefined;
6563
+ targetDirectory = path__namespace.join('packages', scope ? name.replace(`${scope}/`, '') : name);
6411
6564
  }
6412
6565
  }, {
6413
6566
  type: () => !fs__namespace.existsSync(targetDirectory) || isEmpty(targetDirectory) ? null : 'confirm',
@@ -6429,7 +6582,6 @@ async function createPackage(explicitName) {
6429
6582
  }
6430
6583
 
6431
6584
  const {
6432
- name,
6433
6585
  overwrite
6434
6586
  } = result;
6435
6587
  const root = path__namespace.join(cwd, targetDirectory);
@@ -6437,17 +6589,24 @@ async function createPackage(explicitName) {
6437
6589
  if (overwrite) {
6438
6590
  emptyDirectory(root);
6439
6591
  } else if (!fs__namespace.existsSync(root)) {
6440
- fs__namespace.mkdirSync(root);
6592
+ fs__namespace.mkdirSync(root, {
6593
+ recursive: true
6594
+ });
6441
6595
  }
6442
6596
 
6443
- console.log(`\nCreating ${colorette.magenta(toValidPackageName(name))} package in ${colorette.magenta(root)}...`);
6597
+ console.log(`\nCreating ${cyan_1(name)} package in ${cyan_1(path__namespace.relative(cwd, root))}...`);
6444
6598
  const templateRoot = await templateDirectory('package');
6445
6599
  const template = createTemplateFileSystem(templateRoot, root);
6446
6600
 
6447
6601
  for (const file of template.files()) {
6448
6602
  if (file === 'package.json') {
6449
6603
  const packageJson = JSON.parse(template.read(file));
6450
- packageJson.name = toValidPackageName(name);
6604
+ packageJson.name = name;
6605
+
6606
+ if (scope) {
6607
+ packageJson.publishConfig[`${scope}:registry`] = 'https://registry.npmjs.org';
6608
+ }
6609
+
6451
6610
  template.write(file, JSON.stringify(packageJson, null, 2) + os.EOL);
6452
6611
  continue;
6453
6612
  }
@@ -6455,14 +6614,15 @@ async function createPackage(explicitName) {
6455
6614
  template.copy(file);
6456
6615
  }
6457
6616
 
6458
- console.log(`\nDone! Your new package has been created.\n`);
6617
+ console.log(`\nDone! Your new package has been created.`);
6459
6618
  console.log(`Get started by adding source code in the \`source\` directory.`);
6619
+ console.log(`Make sure to edit the \`description\` and \`repository\` sections of your \`package.json\` before publishing.`);
6460
6620
  console.log(`Have fun!`);
6461
6621
  console.log();
6462
6622
  }
6463
6623
 
6464
6624
  async function createApp() {
6465
- const root = path__namespace.join('cwd', 'app');
6625
+ const root = path__namespace.join(cwd, 'app');
6466
6626
 
6467
6627
  if (fs__namespace.existsSync(root)) {
6468
6628
  const {
@@ -6475,10 +6635,12 @@ async function createApp() {
6475
6635
  if (!overwrite) return;
6476
6636
  emptyDirectory(root);
6477
6637
  } else if (!fs__namespace.existsSync(root)) {
6478
- fs__namespace.mkdirSync(root);
6638
+ fs__namespace.mkdirSync(root, {
6639
+ recursive: true
6640
+ });
6479
6641
  }
6480
6642
 
6481
- console.log(`\nCreating app in ${colorette.magenta(root)}...`);
6643
+ console.log(`\nCreating app in ${cyan_1(path__namespace.relative(cwd, root))}...`);
6482
6644
  const templateRoot = await templateDirectory('app');
6483
6645
  const template = createTemplateFileSystem(templateRoot, root);
6484
6646
 
@@ -6493,7 +6655,7 @@ async function createApp() {
6493
6655
  template.copy(file);
6494
6656
  }
6495
6657
 
6496
- console.log(`\nDone! Your new app has been created.\n`);
6658
+ console.log(`\nDone! Your new app has been created.`);
6497
6659
  console.log(`Get started by:`);
6498
6660
  console.log(` * running \`pnpm develop\` to start the development server`);
6499
6661
  console.log(` * editing code in the \`app\` directory`);
@@ -6535,7 +6697,7 @@ async function templateDirectory(name) {
6535
6697
  }
6536
6698
 
6537
6699
  function toValidPackageName(projectName) {
6538
- return projectName.trim().toLowerCase().replace(/\s+/g, '-').replace(/^[._]/, '').replace(/[^a-z0-9-~@]+/g, '-');
6700
+ return projectName.trim().toLowerCase().replace(/\s+/g, '-').replace(/^[._]/, '').replace(/[^a-z0-9-~@/]+/g, '-');
6539
6701
  }
6540
6702
 
6541
6703
  function copy(source, destination) {